List of utility methods to do FileOutputStream Write
void | copyFile(InputStream in, File destination) copy File try (FileOutputStream out = new FileOutputStream(destination)) { byte[] bytes = new byte[65535]; int cnt; while ((cnt = in.read(bytes)) > 0) { out.write(bytes, 0, cnt); |
void | copyFile(InputStream in, File destination) copy File if (!destination.canWrite()) throw new Exception("Creating of temporary file for lens failed. Destination file " + destination.getAbsolutePath() + " is not accessible."); OutputStream out = new FileOutputStream(destination); byte[] buf = new byte[1024]; int length; while ((length = in.read(buf)) > 0) { out.write(buf, 0, length); ... |
void | copyFile(InputStream input, File outFile) Copy an InputStream to a file. OutputStream os = new FileOutputStream(outFile); try { byte[] buffer = new byte[COPY_BUFFER_SIZE]; int readLen; while ((readLen = input.read(buffer)) != -1) { os.write(buffer, 0, readLen); } finally { ... |
File | copyFile(InputStream input, File outputLocation) copy File if (!outputLocation.exists()) { outputLocation.createNewFile(); FileOutputStream dest = new FileOutputStream(outputLocation); int read = 0; byte[] bytes = new byte[1024]; while ((read = input.read(bytes)) != -1) { dest.write(bytes, 0, read); ... |
long | copyFile(InputStream input, OutputStream output) copy File byte buffer[] = new byte[2048]; long count = 0; int n = 0; while (-1 != (n = input.read(buffer))) { output.write(buffer, 0, n); count += n; return count; ... |
void | copyFile(InputStream sourceFileIs, File destDirFile, String destFileName) copy File int c; StringBuffer fileSb = new StringBuffer(); while ((c = sourceFileIs.read()) != -1) { fileSb.append((char) c); String fileStr = fileSb.toString(); File f = new File(destDirFile, destFileName); FileOutputStream fos = new FileOutputStream(f); ... |
void | copyFileFromAssets(InputStream inputStream, String pathToWrite) copy File From Assets OutputStream outputStream = null; try { File newFile = new File(pathToWrite); if (!newFile.exists()) { newFile.createNewFile(); outputStream = new FileOutputStream(new File(pathToWrite)); int read = 0; ... |
void | copyFileUsingFileStreams(InputStream source, File dest) copy File Using File Streams OutputStream output = null; try { output = new FileOutputStream(dest); byte[] buf = new byte[1024]; int bytesRead; while ((bytesRead = source.read(buf)) > 0) { output.write(buf, 0, bytesRead); } finally { try { source.close(); output.close(); } catch (Exception ex) { ex.printStackTrace(); |
void | copyFileUsingStream(InputStream sourceStream, File dest) Copy file from a given InputStream to a destination file if (sourceStream == null) { throw new IllegalArgumentException("Source stream is null"); OutputStream destStream = null; try { destStream = new FileOutputStream(dest); byte[] buffer = new byte[1024]; int length; ... |
void | save(byte[] bs, String fn) save new File(fn).getParentFile().mkdirs(); BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(fn)); out.write(bs); out.close(); |