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


Java FileUtils.copyFile方法代码示例

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


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

示例1: loadSound

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public void loadSound(File source)
{
    lastOpenedSound=source.getAbsolutePath();
    File dest = new File(getSoundDirectory()+source.getName());
    //System.out.println(source);
    //System.out.println(dest);
    try 
    {
        FileUtils.copyFile(source, dest);
    } 
    catch (IOException ex) 
    {
        ex.printStackTrace();
        JOptionPane.showMessageDialog(frame, "A terrible error occured!\n"+
                ex.getMessage()+"\n","Error", JOptionPane.ERROR_MESSAGE,Moenagade.IMG_ERROR);
    }
}
 
开发者ID:fesch,项目名称:Moenagade,代码行数:18,代码来源:Project.java

示例2: loadImage

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public void loadImage(File source)
{
    lastOpenedImage=source.getAbsolutePath();
    File dest = new File(getImageDirectory()+source.getName());
    //System.out.println(source);
    //System.out.println(dest);
    try 
    {
        FileUtils.copyFile(source, dest);
    } 
    catch (IOException ex) 
    {
        ex.printStackTrace();
        JOptionPane.showMessageDialog(frame, "A terrible error occured!\n"+
                ex.getMessage()+"\n","Error", JOptionPane.ERROR_MESSAGE,Moenagade.IMG_ERROR);
    }
}
 
开发者ID:fesch,项目名称:Moenagade,代码行数:18,代码来源:Project.java

示例3: addFile

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static boolean addFile(File zipFile, String path, File file) throws IOException {

        if (file.isDirectory()) {
            return false;
        }

        File rootDir = new File(file.getParentFile(), "_tmp");
        rootDir.delete();

        FileUtils.copyFile(file, new File(rootDir, path));

        //zip -r taobao-android-debug.apk zzzz
        boolean success = CmdExecutor.execute(rootDir.getAbsolutePath(), "zip", "-r", zipFile.getAbsolutePath(), path);

        rootDir.delete();
        if (success) {
            return true;
        }

        File tmpFile = new File(zipFile.getParentFile(), zipFile.getName() + "_tmp");
        ZipUtils.addFileToZipFile(zipFile, tmpFile, file, path, true);
        zipFile.delete();
        tmpFile.renameTo(zipFile);

        return true;
    }
 
开发者ID:alibaba,项目名称:atlas,代码行数:27,代码来源:BetterZip.java

示例4: checkFolder

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private void checkFolder() {
	File folder = getResourceFolder();
	File templateFolder = new File(Engine.TEMPLATES_PATH, "base/DisplayObjects/platforms/" + getClass().getSimpleName());

	try {
		if (!folder.exists()) {
			FileUtils.copyDirectory(templateFolder, folder);
		} else {
			File config = new File(folder, "config.xml");
			if (!config.exists()) {
				FileUtils.copyFile(new File(templateFolder, "config.xml"), config);
			}
			File res = new File(folder, "res");
			if (!res.exists()) {
				FileUtils.copyDirectory(new File(templateFolder, "res"), res);
			}
		}
	} catch (IOException e) {
		Engine.logBeans.warn("(MobilePlatform) The folder '" + folder.getAbsolutePath() + "' doesn't exist and cannot be created", e);
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:22,代码来源:MobilePlatform.java

示例5: exec

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Override
  public BaseResponse exec(ImportFileRequest request, EntityManager em) throws Exception {
      BaseResponse response = new BaseResponse();
      File tmpUploadFolder = new File(request.getUploadPath());

      try {
validate(em, request, tmpUploadFolder);

File pluginTarget = new File(ApiFactoryService.PLUGINS_DIRECTORY, this.deploymentName);

FileUtils.copyFile(this.barFile, pluginTarget);

      } finally {
          cleanTmpFolder(tmpUploadFolder);
      }
      return response;
  }
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:18,代码来源:ImportPluginService.java

示例6: createScreenshot

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static void createScreenshot(String fileName) {

		if (SeleniumDriver.getInstance() instanceof TakesScreenshot) {

			File fileSrc = ((TakesScreenshot) SeleniumDriver.getInstance()).getScreenshotAs(OutputType.FILE);

			try {
				File destFile = new File(String.format(SCREENSHOTS_FORMAT, fileName));
				FileUtils.copyFile(fileSrc, destFile);
				LOG.info("[Screenshot] " + destFile.getAbsolutePath());
			} catch (IOException e) {
				;
			}
		}

	}
 
开发者ID:entelgy-brasil,项目名称:zucchini,代码行数:17,代码来源:ScreenshotHook.java

示例7: send

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Override
protected void send(Path path) throws Exception
{
	Part part = new Part(APPLICATION_DICOM);
	out.addPart(part);
	
	if (acceptableTransferSyntaxes.contains("*")) {
		// Client accepts any transfer syntax so just send the file
		FileUtils.copyFile(path.toFile(), out);
	}
	else {
		String tx = DicomUtil.getTransferSyntax(path);
		if (acceptableTransferSyntaxes.contains(tx)) {
			// Client accepts the transfer syntax of the file, so just send it
			FileUtils.copyFile(path.toFile(), out);
		}
		else {
			// Client does not accept the transfer syntax of the file, so we transcode it to LEE
			try (Transcoder transcoder = new Transcoder(path.toFile())) {
				transcoder.setDestinationTransferSyntax(ExplicitVRLittleEndian);
				transcoder.setIncludeFileMetaInformation(true);
				transcoder.setCloseInputStream(true);
				transcoder.setCloseOutputStream(false);
				transcoder.setIncludeBulkData(DicomInputStream.IncludeBulkData.YES);
				
				transcoder.transcode((Transcoder t, Attributes dataset) -> out);
			}
		}
	}
}
 
开发者ID:RSNA,项目名称:dcmrs-broker,代码行数:31,代码来源:DicomMultipartResponse.java

示例8: copyFile

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static void copyFile(File source, File destination) {
    try {
        FileUtils.copyFile(source, destination);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:8,代码来源:GFileUtils.java

示例9: takeScreenshot

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static Boolean takeScreenshot(SeleniumDriver seleniumdriver, String imgSrc) {
    try {
        File scrFile = seleniumdriver.createScreenShot();
        if (scrFile != null) {
            File imgFile = new File(FilePath.getCurrentResultsPath() + imgSrc);
            FileUtils.copyFile(scrFile, imgFile, true);
            scrFile.delete();
            return true;
        }
    } catch (Exception ex) {
        Logger.getLogger(ReportUtils.class.getName()).log(Level.SEVERE, null, ex);
    }
    return false;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:15,代码来源:ReportUtils.java

示例10: journalFileIsPreferredOverBackupFile

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Test public void journalFileIsPreferredOverBackupFile() throws Exception {
    DiskLruCacheWithExpiry.Editor creator = cache.edit("k1");
    creator.set(0, "ABC");
    creator.set(1, "DE");
    creator.commit();
    cache.flush();

    FileUtils.copyFile(journalFile, journalBkpFile);

    creator = cache.edit("k2");
    creator.set(0, "F");
    creator.set(1, "GH");
    creator.commit();
    cache.close();

    assertThat(journalFile.exists()).isTrue();
    assertThat(journalBkpFile.exists()).isTrue();

    cache = DiskLruCacheWithExpiry.open(cacheDir, appVersion, 2, Integer.MAX_VALUE);

    DiskLruCacheWithExpiry.Snapshot snapshotA = cache.get("k1");
    assertThat(snapshotA.getString(0)).isEqualTo("ABC");
    assertThat(snapshotA.getLength(0)).isEqualTo(3);
    assertThat(snapshotA.getString(1)).isEqualTo("DE");
    assertThat(snapshotA.getLength(1)).isEqualTo(2);

    DiskLruCacheWithExpiry.Snapshot snapshotB = cache.get("k2");
    assertThat(snapshotB.getString(0)).isEqualTo("F");
    assertThat(snapshotB.getLength(0)).isEqualTo(1);
    assertThat(snapshotB.getString(1)).isEqualTo("GH");
    assertThat(snapshotB.getLength(1)).isEqualTo(2);

    assertThat(journalBkpFile.exists()).isFalse();
    assertThat(journalFile.exists()).isTrue();
}
 
开发者ID:myntra,项目名称:ObjectCache,代码行数:36,代码来源:DiskLruCacheTest.java

示例11: randomModel_closed_7

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Test
public void randomModel_closed_7() throws IOException, URISyntaxException {
	CommandLineSolver solver = new CommandLineSolver();

	File input = File.createTempFile("randomModel_closed_7", ".xml");
	File expected = new File(getClass().getResource("randomModel_closed_7-expectedOutput.xml").toURI());
	FileUtils.copyFile(new File(getClass().getResource("randomModel_closed_7-input.xml").toURI()), input);

	assertTrue("Solver was not able to solve file!", solver.solve(input));
	assertTrue(": Real output differs from expected!\n"
			+ "Expected: \n" + FileUtils.readFileToString(expected)
			+ "\nActual: \n" + FileUtils.readFileToString(input), 
			FileUtils.contentEquals(input, expected));			
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:15,代码来源:JmvaClosedModelTest.java

示例12: randomModel_closed_12

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Test
public void randomModel_closed_12() throws IOException, URISyntaxException {
	CommandLineSolver solver = new CommandLineSolver();

	File input = File.createTempFile("randomModel_closed_12", ".xml");
	File expected = new File(getClass().getResource("randomModel_closed_12-expectedOutput.xml").toURI());
	FileUtils.copyFile(new File(getClass().getResource("randomModel_closed_12-input.xml").toURI()), input);

	assertTrue("Solver was not able to solve file!", solver.solve(input));
	assertTrue(": Real output differs from expected!\n"
			+ "Expected: \n" + FileUtils.readFileToString(expected)
			+ "\nActual: \n" + FileUtils.readFileToString(input), 
			FileUtils.contentEquals(input, expected));			
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:15,代码来源:JmvaClosedModelTest.java

示例13: randomModel_open_1

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Test
public void randomModel_open_1() throws IOException, URISyntaxException {
	CommandLineSolver solver = new CommandLineSolver();

	File input = File.createTempFile("randomModel_open_1", ".xml");
	File expected = new File(getClass().getResource("randomModel_open_1-expectedOutput.xml").toURI());
	FileUtils.copyFile(new File(getClass().getResource("randomModel_open_1-input.xml").toURI()), input);

	assertTrue("Solver was not able to solve file!", solver.solve(input));
	assertTrue(": Real output differs from expected!\n"
			+ "Expected: \n" + FileUtils.readFileToString(expected)
			+ "\nActual: \n" + FileUtils.readFileToString(input), 
			FileUtils.contentEquals(input, expected));			
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:15,代码来源:JmvaOpenModelTest.java

示例14: randomModel_mixed_2

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Test
public void randomModel_mixed_2() throws IOException, URISyntaxException {
	CommandLineSolver solver = new CommandLineSolver();

	File input = File.createTempFile("randomModel_mixed_2", ".xml");
	File expected = new File(getClass().getResource("randomModel_mixed_2-expectedOutput.xml").toURI());
	FileUtils.copyFile(new File(getClass().getResource("randomModel_mixed_2-input.xml").toURI()), input);

	assertTrue("Solver was not able to solve file!", solver.solve(input));
	assertTrue(": Real output differs from expected!\n"
			+ "Expected: \n" + FileUtils.readFileToString(expected)
			+ "\nActual: \n" + FileUtils.readFileToString(input), 
			FileUtils.contentEquals(input, expected));			
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:15,代码来源:JmvaMixedModelTest.java

示例15: testVisualDiff

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Test
public void testVisualDiff() throws Exception {
  XulMessageBox message = spy( new XulMessageBoxMock( XulDialogCallback.Status.ACCEPT ) );
  when( document.createElement( MESSAGEBOX ) ).thenReturn( message );
  UIFile file = new UIFile( "test.txt", ChangeType.MODIFY, true );
  doReturn( Collections.singletonList( file ) ).when( controller ).getSelectedChangedFiles();
  controller.visualdiff();
  verify( message ).setTitle( BaseMessages.getString( PKG, "Dialog.Error" ) );

  // .ktr
  file = new UIFile( "test.ktr", ChangeType.MODIFY, true );
  doReturn( Collections.singletonList( file ) ).when( controller ).getSelectedChangedFiles();
  doReturn( new FileInputStream( new File( "src/test/resources/r1.ktr" ) ) ).when( uiGit ).open( "test.ktr", Constants.HEAD );
  doReturn( new FileInputStream( new File( "src/test/resources/r2.ktr" ) ) ).when( uiGit ).open( "test.ktr", IVCS.WORKINGTREE );
  controller.visualdiff();
  verify( uiGit ).open( "test.ktr", Constants.HEAD );
  verify( uiGit ).open( "test.ktr", IVCS.WORKINGTREE );
  verify( controller ).loadMainPerspective();

  // conflicted ktr
  file = new UIFile( "test.kjb.ours", ChangeType.ADD, false );
  File dir = File.createTempFile( "git_test_", "_controller" );
  dir.delete();
  dir.mkdir();
  File ours = new File( dir.getPath(), "test.kjb.ours" );
  File theirs = new File( dir.getPath(), "test.kjb.theirs" );
  FileUtils.copyFile( new File( "src/test/resources/r1.kjb" ), ours );
  FileUtils.copyFile( new File( "src/test/resources/r2.kjb" ), theirs );
  doReturn( dir.getPath() ).when( uiGit ).getDirectory();
  doReturn( Collections.singletonList( file ) ).when( controller ).getSelectedChangedFiles();
  doReturn( new FileInputStream( ours ) ).when( uiGit ).open( "test.kjb.ours", IVCS.WORKINGTREE );
  doReturn( new FileInputStream( theirs ) ).when( uiGit ).open( "test.kjb.theirs", IVCS.WORKINGTREE );
  controller.visualdiff();
  FileUtils.deleteDirectory( dir );
  verify( uiGit ).open( "test.kjb.ours", IVCS.WORKINGTREE );
  verify( uiGit ).open( "test.kjb.theirs", IVCS.WORKINGTREE );
  verify( controller, times( 2 ) ).loadMainPerspective();
}
 
开发者ID:HiromuHota,项目名称:pdi-git-plugin,代码行数:39,代码来源:GitControllerTest.java


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