List of utility methods to do BufferedInputStream Copy
String | copyFileFromZipToDir(String zipFile, String fileNamePattern, File dir) copy File From Zip To Dir ZipFile zip = new ZipFile(zipFile); Enumeration zipFileEntries = zip.entries(); int BUFFER = 2048; while (zipFileEntries.hasMoreElements()) { ZipEntry entry = (ZipEntry) zipFileEntries.nextElement(); String currentEntry = entry.getName(); if (currentEntry.matches(fileNamePattern)) { String[] currentEntrySegments = currentEntry.split(File.separator); ... |
boolean | copyFileNormal(File copyFrom, File copyTo) copy File Normal if (!copyFrom.exists() || copyTo == null) { return false; byte[] arrayOfByte = new byte[4096]; BufferedInputStream input = new BufferedInputStream(new FileInputStream(copyFrom)); BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(copyTo, false)); int i; while ((i = input.read(arrayOfByte, 0, arrayOfByte.length)) != -1) { ... |
void | copyFileToFile(File in, File out) Copies one bin file to other int b; BufferedInputStream is = new BufferedInputStream(new FileInputStream(in)); BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(out)); while ((b = is.read()) != -1) { os.write(b); is.close(); os.close(); ... |
void | copyFileToStream(File from, OutputStream out) copy File To Stream InputStream in = new BufferedInputStream(new FileInputStream(from)); try { copyStream(in, out); } finally { in.close(); |
void | copyFileToStream(File input, OutputStream os) copy File To Stream InputStream is = new BufferedInputStream(new FileInputStream(input)); copyStreamToStream(is, os); is.close(); |
File | copyFileToTemp(InputStream is, String dirName, String fileName) copy File To Temp File path = new File(System.getProperty("java.io.tmpdir") + "/" + dirName); File outputfile = new File(path + "/" + fileName); try { if (path.exists() == false) { path.mkdir(); if (outputfile.exists() == false) { outputfile.createNewFile(); ... |
File | copyFileUnique(File in, File outDir) Write file with an unique name. if (in.isFile() == false || outDir.isDirectory() == false) { return null; int n = 0; String name = getWithoutExtension(in.getName()); String ext = getExtension(in.getName()); File out = new File(outDir.getPath() + File.separator + in.getName()); while (out.isFile()) { ... |