本文整理汇总了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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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) {
;
}
}
}
示例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);
}
}
}
}
示例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);
}
}
示例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;
}
示例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();
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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();
}