@Test public void copy() throws IOException { File fileOne = File.createTempFile("one", ".txt"); File fileTwo = File.createTempFile("two", ".txt"); String content = "testing" + System.currentTimeMillis(); FileWriter writer = new FileWriter(fileOne); writer.write(content); writer.close(); FileUtil.copy(fileOne, fileTwo); FileInputStream stream = new FileInputStream(fileTwo); FileChannel fc = stream.getChannel(); MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size()); String copied = Charset.defaultCharset().decode(bb).toString(); stream.close(); assertEquals(content, copied); }
public static boolean copy(File from, File to) { try { return copy(new BufferedInputStream(new FileInputStream(from)), to); } catch (FileNotFoundException fnfe) { Output.print(fnfe); } return false; }
FileUtil { public static boolean copy(File from, File to) { try { return copy(new BufferedInputStream(new FileInputStream(from)), to); } catch (FileNotFoundException fnfe) { Output.print(fnfe); } return false; } }
FileUtil { public static boolean copy(File from, File to) { try { return copy(new BufferedInputStream(new FileInputStream(from)), to); } catch (FileNotFoundException fnfe) { Output.print(fnfe); } return false; } private  FileUtil(); }
FileUtil { public static boolean copy(File from, File to) { try { return copy(new BufferedInputStream(new FileInputStream(from)), to); } catch (FileNotFoundException fnfe) { Output.print(fnfe); } return false; } private  FileUtil(); static boolean copyDir(File fromDir, File toDir); static boolean copyDir(File fromDir, File toDir, FilenameFilter excluding); static boolean copy(File from, File to); static boolean copy(URL from, File to); static boolean copy(InputStream from, File to); static String getLocalPath(URL url, Map<String, String> headers, String name, String intoName); static boolean download(URL remoteUrl, Map<String, String> headers, File into, String name, String intoName, boolean ignoreFNF); static URL getUrl(String path); static InputStream downloadToStream(URL remoteUrl, Map<String, String> headers); static String pathFromParts(String ... parts); static File fromParts(String ... parts); static String resolveUnixTilde(String path); static String reverseUnixTilde(String path); static boolean isLocalPath(String path); static String encodeForURI(String filePath); static void delete(File file); static String getCanonicalPath(File file); static String stripFileUriPrefix(String path); static String getSha1Hash(File file); }
FileUtil { public static boolean copy(File from, File to) { try { return copy(new BufferedInputStream(new FileInputStream(from)), to); } catch (FileNotFoundException fnfe) { Output.print(fnfe); } return false; } private  FileUtil(); static boolean copyDir(File fromDir, File toDir); static boolean copyDir(File fromDir, File toDir, FilenameFilter excluding); static boolean copy(File from, File to); static boolean copy(URL from, File to); static boolean copy(InputStream from, File to); static String getLocalPath(URL url, Map<String, String> headers, String name, String intoName); static boolean download(URL remoteUrl, Map<String, String> headers, File into, String name, String intoName, boolean ignoreFNF); static URL getUrl(String path); static InputStream downloadToStream(URL remoteUrl, Map<String, String> headers); static String pathFromParts(String ... parts); static File fromParts(String ... parts); static String resolveUnixTilde(String path); static String reverseUnixTilde(String path); static boolean isLocalPath(String path); static String encodeForURI(String filePath); static void delete(File file); static String getCanonicalPath(File file); static String stripFileUriPrefix(String path); static String getSha1Hash(File file);  }