當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。