当前位置: 首页>>代码示例>>Java>>正文


Java FileUtil.copy方法代码示例

本文整理汇总了Java中com.intellij.openapi.util.io.FileUtil.copy方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.copy方法的具体用法?Java FileUtil.copy怎么用?Java FileUtil.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.util.io.FileUtil的用法示例。


在下文中一共展示了FileUtil.copy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getVirtualFile

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private void getVirtualFile(String sourceName, VirtualFile virtualFile[], String compileRoot)
        throws Exception {
    if (!ArrayUtils.isEmpty(virtualFile)) {
        VirtualFile arr$[] = virtualFile;
        int len$ = arr$.length;
        for (int i$ = 0; i$ < len$; i$++) {
            VirtualFile vf = arr$[i$];
            String srcName;
            if (StringUtils.indexOf(vf.toString(), "$") != -1)
                srcName = StringUtils.substring(vf.toString(), StringUtils.lastIndexOf(vf.toString(), "/") + 1, StringUtils.indexOf(vf.toString(), "$"));
            else
                srcName = StringUtils.substring(vf.toString(), StringUtils.lastIndexOf(vf.toString(), "/") + 1, StringUtils.length(vf.toString()) - 6);
            String dstName = StringUtils.substring(sourceName, 0, StringUtils.length(sourceName) - 5);
            if (StringUtils.equals(srcName, dstName)) {
                String outRoot = (new StringBuilder()).append(StringUtils.substring(compileRoot, 0, StringUtils.lastIndexOf(compileRoot, "/"))).append("/out").toString();
                String packagePath = StringUtils.substring(vf.getPath(), StringUtils.length(compileRoot), StringUtils.length(vf.getPath()));
                File s = new File(vf.getPath());
                File t = new File((new StringBuilder()).append(outRoot).append(packagePath).toString());
                FileUtil.copy(s, t);
            }
            if (!ArrayUtils.isEmpty(virtualFile))
                getVirtualFile(sourceName, vf.getChildren(), compileRoot);
        }

    }
}
 
开发者ID:serical,项目名称:patcher,代码行数:27,代码来源:ClassesExportAction.java

示例2: getCopyOfCompilerManifestFile

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Nullable
protected static Pair<File, String> getCopyOfCompilerManifestFile(@NotNull AndroidFacet facet, @Nullable ProcessHandler processHandler) {
  final VirtualFile manifestFile = AndroidRootUtil.getCustomManifestFileForCompiler(facet);

  if (manifestFile == null) {
    return null;
  }
  File tmpDir = null;
  try {
    tmpDir = FileUtil.createTempDirectory("android_manifest_file_for_execution", "tmp");
    final File manifestCopy = new File(tmpDir, manifestFile.getName());
    FileUtil.copy(new File(manifestFile.getPath()), manifestCopy);
    //noinspection ConstantConditions
    return Pair.create(manifestCopy, PathUtil.getLocalPath(manifestFile));
  }
  catch (IOException e) {
    if (processHandler != null) {
      processHandler.notifyTextAvailable("I/O error: " + e.getMessage(), ProcessOutputTypes.STDERR);
    }
    LOG.info(e);
    if (tmpDir != null) {
      FileUtil.delete(tmpDir);
    }
    return null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:AndroidRunConfigurationBase.java

示例3: walk

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private static void walk(File root, MultiMap<Couple<Integer>, String> dimToPath, File file) throws IOException {
  if (file.isDirectory()) {
    for (File child : file.listFiles()) {
      walk(root, dimToPath, child);
    }
  }
  else {
    if (IMAGE_EXTENSIONS.contains(FileUtilRt.getExtension(file.getName()))) {
      String relativePath = file.getAbsolutePath().substring(root.getAbsolutePath().length() + 1);
      Image image = loadImage(file);
      File target;
      int width = image.getWidth(null);
      int height = image.getHeight(null);
      if (height != width && (height > 100 || width > 100)) {
        target = new File("/Users/max/images/other", relativePath);
      }
      else {
        target = new File("/Users/max/images/icons", relativePath);
        dimToPath.putValue(new Couple<Integer>(width, height), relativePath);
      }
      FileUtil.copy(file, target);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:BuildIcons.java

示例4: createCourse

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
/**
 * Creates course directory in project user created
 *
 * @param baseDir      project directory
 * @param resourceRoot directory where original course is stored
 */
public static void createCourse(@NotNull final Course course, @NotNull final VirtualFile baseDir, @NotNull final File resourceRoot,
                                @NotNull final Project project) {

            try {
              final List<Lesson> lessons = course.getLessons();
              for (int i = 1; i <= lessons.size(); i++) {
                Lesson lesson = lessons.get(i - 1);
                lesson.setIndex(i);
                createLesson(lesson, baseDir, resourceRoot, project);
              }
              baseDir.createChildDirectory(project, EduNames.SANDBOX_DIR);
              File[] files = resourceRoot.listFiles(new FilenameFilter() {
                @Override
                public boolean accept(File dir, String name) {
                  return !name.contains(EduNames.LESSON) && !name.equals(EduNames.COURSE_META_FILE) && !name.equals(EduNames.HINTS);
                }
              });
              for (File file : files) {
                FileUtil.copy(file, new File(baseDir.getPath(), file.getName()));
              }
            }
            catch (IOException e) {
              LOG.error(e);
            }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:StudyGenerator.java

示例5: failOnEmptySourceJar

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Test
public void failOnEmptySourceJar() throws Exception {
  final File sourceJar = new File(myOlderDir, "lib/empty.jar");
  if (sourceJar.exists()) sourceJar.delete();
  assertTrue(sourceJar.createNewFile());

  try {
    final File targetJar = new File(myNewerDir, "lib/empty.jar");
    FileUtil.copy(new File(myNewerDir, "lib/annotations.jar"), targetJar);

    try {
      createPatch();
      fail("Should have failed to create a patch from empty .jar");
    }
    catch (IOException e) {
      final String reason = e.getMessage();
      assertEquals("Corrupted source file: " + sourceJar, reason);
    }
    finally {
      targetJar.delete();
    }
  }
  finally {
    sourceJar.delete();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:PatchFileCreatorNotBinaryTest.java

示例6: updateStatus

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
/**
 * Post on twitter media and text from panel
 * @param panel shown to user and used to provide data to post 
 */
public static void updateStatus(StudyTwitterUtils.TwitterDialogPanel panel, Twitter twitter) throws IOException, TwitterException {
  StatusUpdate update = new StatusUpdate(panel.getMessage());
  InputStream e = panel.getMediaSource();
  if (e != null) {
    File imageFile = FileUtil.createTempFile("twitter_media", panel.getMediaExtension());
    FileUtil.copy(e, new FileOutputStream(imageFile));
    update.media(imageFile);
  }

  twitter.updateStatus(update);
  BrowserUtil.browse("https://twitter.com/");
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:17,代码来源:StudyTwitterUtils.java

示例7: copyConfigFile

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private static void copyConfigFile(Project project, File temp, String fileName) throws IOException {
    VirtualFile jscs = project.getBaseDir().findChild(fileName);
    File tempJscs = new File(temp, fileName);
    if (jscs != null) {
        FileUtil.copy(new File(jscs.getPath()), tempJscs);
        tempJscs.deleteOnExit();
    }
}
 
开发者ID:sertae,项目名称:stylint-plugin,代码行数:9,代码来源:StylintExternalAnnotator.java

示例8: copyStreamToFile

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private static File copyStreamToFile(final InputStream stream, final File file) throws IOException {
  try {
    final FileOutputStream outputStream = new FileOutputStream(file);
    try {
      FileUtil.copy(stream, outputStream);
    }
    finally {
      outputStream.close();
    }
  }
  finally {
    stream.close();
  }
  return file;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:CopyResourcesUtil.java

示例9: shouldProcess

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public boolean shouldProcess(VirtualFile virtualFile, File targetFile) throws IOException {
  if (isProjectOrModuleFile(virtualFile) && myUpdatedFilesInfo.isMerged(targetFile)) {
    myUpdatedFilesInfo.couldNotUpdateFile(targetFile);      
    File backupCopy = getCopyFor(virtualFile, targetFile);
    myPostCvsActivity.registerCorruptedProjectOrModuleFile(
      new MergedWithConflictProjectOrModuleFile(virtualFile));
    FileUtil.copy(backupCopy, targetFile);
    return false;
  }
  else {
    return true;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:UpdateReceivedFileProcessor.java

示例10: copyBaseSdkSkeletonsToVirtualEnv

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private void copyBaseSdkSkeletonsToVirtualEnv(String skeletonsPath, PySkeletonGenerator.ListBinariesResult binaries)
  throws InvalidSdkException {
  final Sdk base = PythonSdkType.getInstance().getVirtualEnvBaseSdk(mySdk);
  if (base != null) {
    indicate("Copying base SDK skeletons for virtualenv...");
    final String baseSkeletonsPath = PythonSdkType.getSkeletonsPath(PathManager.getSystemPath(), base.getHomePath());
    final PySkeletonGenerator.ListBinariesResult baseBinaries =
      mySkeletonsGenerator.listBinaries(base, calculateExtraSysPath(base, baseSkeletonsPath));
    for (Map.Entry<String, PyBinaryItem> entry : binaries.modules.entrySet()) {
      final String module = entry.getKey();
      final PyBinaryItem binary = entry.getValue();
      final PyBinaryItem baseBinary = baseBinaries.modules.get(module);
      final File fromFile = getSkeleton(module, baseSkeletonsPath);
      if (baseBinaries.modules.containsKey(module) &&
          fromFile.exists() &&
          binary.length() == baseBinary.length()) { // Weak binary modules equality check
        final File toFile = fromFile.isDirectory() ?
                            getPackageSkeleton(module, skeletonsPath) :
                            getModuleSkeleton(module, skeletonsPath);
        try {
          FileUtil.copy(fromFile, toFile);
        }
        catch (IOException e) {
          LOG.info("Error copying base virtualenv SDK skeleton for " + module, e);
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:PySkeletonRefresher.java

示例11: testDocumentReuse

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public void testDocumentReuse() throws IOException {
  File classFile = new File(FileUtil.getTempDirectory(), "ReuseTest.class");
  FileUtil.writeToFile(classFile, "");
  VirtualFile vFile = StandardFileSystems.local().findFileByPath(classFile.getPath());
  assertNotNull(classFile.getPath(), vFile);
  PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(vFile);
  assertNotNull(psiFile);
  String testDir = getTestDataDir();

  FileUtil.copy(new File(testDir, "pkg/ReuseTestV1.class"), classFile);
  vFile.refresh(false, false);
  PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
  String text1 = psiFile.getText();
  assertTrue(text1, text1.contains("private int f1"));
  assertFalse(text1, text1.contains("private int f2"));
  Document doc1 = FileDocumentManager.getInstance().getCachedDocument(vFile);
  assertNotNull(doc1);
  assertSame(doc1, PsiDocumentManager.getInstance(getProject()).getDocument(psiFile));

  FileUtil.copy(new File(testDir, "pkg/ReuseTestV2.class"), classFile);
  vFile.refresh(false, false);
  PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
  String text2 = psiFile.getText();
  assertTrue(text2, text2.contains("private int f1"));
  assertTrue(text2, text2.contains("private int f2"));
  Document doc2 = FileDocumentManager.getInstance().getCachedDocument(vFile);
  assertNotNull(doc2);
  assertSame(doc2, PsiDocumentManager.getInstance(getProject()).getDocument(psiFile));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:ClsMirrorBuildingTest.java

示例12: backupFiles

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public static void backupFiles(Collection<File> files, File parentDir, File backupDir) throws IOException {
  backupDir.mkdirs();
  for (File file : files) {
    final File target;
    if (FileUtil.isAncestor(parentDir, file, true)) {
      final String relativePath = FileUtil.getRelativePath(parentDir, file);
      target = new File(backupDir.getAbsolutePath() + File.separator + relativePath);
      FileUtil.createParentDirs(target);
    }
    else {
      target = new File(backupDir, file.getName());
    }
    FileUtil.copy(file, target);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ProjectConversionUtil.java

示例13: copyFile

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private static void copyFile(@NotNull final File from, @NotNull final File to) {
  if (from.exists()) {
    try {
      FileUtil.copy(from, to);
    }
    catch (IOException e) {
      LOG.warn("Failed to copy " + from.getName());
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:StudyProjectComponent.java

示例14: testApplyWhenCommonFileChanges

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Test
public void testApplyWhenCommonFileChanges() throws Exception {
  Patch patch = PatchFileCreator.create(myPatchSpec, myFile, TEST_UI);

  FileUtil.copy(new File(myOlderDir, "/lib/bootstrap.jar"),
                new File(myOlderDir, "/lib/boot.jar"));

  PatchFileCreator.PreparationResult preparationResult = PatchFileCreator.prepareAndValidate(myFile, myOlderDir, TEST_UI);
  assertTrue(preparationResult.validationResults.isEmpty());
  assertAppliedAndRevertedCorrectly(patch, preparationResult);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:PatchFileCreatorTest.java

示例15: testApplyWhenCommonFileChangesStrict

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Test
public void testApplyWhenCommonFileChangesStrict() throws Exception {
  myPatchSpec.setStrict(true);
  PatchFileCreator.create(myPatchSpec, myFile, TEST_UI);

  FileUtil.copy(new File(myOlderDir, "/lib/bootstrap.jar"), new File(myOlderDir, "/lib/boot.jar"));

  PatchFileCreator.PreparationResult preparationResult = PatchFileCreator.prepareAndValidate(myFile, myOlderDir, TEST_UI);
  assertEquals(1, preparationResult.validationResults.size());
  assertEquals(
    new ValidationResult(ValidationResult.Kind.ERROR, "lib/boot.jar", ValidationResult.Action.VALIDATE, ValidationResult.MODIFIED_MESSAGE,
                         ValidationResult.Option.NONE), preparationResult.validationResults.get(0));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:PatchFileCreatorTest.java


注:本文中的com.intellij.openapi.util.io.FileUtil.copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。