List of utility methods to do FileInputStream Copy
void | copyFileToStream(File file, OutputStream stream) Copies the data from file into the stream. InputStream input = null; try { input = new FileInputStream(file); copyStream(input, stream); } finally { if (input != null) input.close(); |
String | copyFileToString(java.io.File f) Returns a string which contains the contents of a file. int s = (int) f.length(); byte[] data = new byte[s]; int len = new FileInputStream(f).read(data); if (len != s) throw new EOFException("truncated file"); return new String(data); |
int | copyFileToZip(final ZipOutputStream zos, final byte[] readBuffer, final File file, final int bytesInOfZip) copy File To Zip final FileInputStream fis = new FileInputStream(file); int bytesIn = bytesInOfZip; try { while ((bytesIn = fis.read(readBuffer)) != -1) { zos.write(readBuffer, 0, bytesIn); } finally { fis.close(); ... |
void | copyFileUsingFileStreams(final File source, final File dest) copy File Using File Streams InputStream input = null; OutputStream output = null; try { FileInputStream _fileInputStream = new FileInputStream(source); input = _fileInputStream; FileOutputStream _fileOutputStream = new FileOutputStream(dest); output = _fileOutputStream; byte[] buf = new byte[1024]; ... |
void | copyFileUsingStream(File source, File dest) copy File Using Stream InputStream is = null; OutputStream os = null; try { is = new FileInputStream(source); os = new FileOutputStream(dest); byte[] buffer = new byte[1024]; int length; while ((length = is.read(buffer)) > 0) { ... |
void | copyFileUsingStream(String source_path, String dest_path) copy File Using Stream File source = new File(source_path); File dest = new File(dest_path); InputStream is = null; OutputStream os = null; try { is = new FileInputStream(source); os = new FileOutputStream(dest); byte[] buffer = new byte[1024]; ... |