List of utility methods to do FileOutputStream Create
boolean | writeFileFromString(File outputFileName, String content) ouputs a new file try { FileOutputStream fos2 = new FileOutputStream(outputFileName, false); fos2.write(content.getBytes()); fos2.close(); } catch (IOException ioe) { return false; return true; ... |
void | writeFileRaw(String fileName, byte[][] contents) Method to write raw content to the file. try (OutputStream output = new BufferedOutputStream(new FileOutputStream(fileName))) { for (byte[] content : contents) { output.write(content); output.flush(); |
void | writeFileToByte(byte[] bytes, File file) write File To Byte FileOutputStream fileOutputStream = null;
fileOutputStream = new FileOutputStream(file);
fileOutputStream.write(bytes);
fileOutputStream.close();
|
Boolean | writeFileToDisk(ByteArrayOutputStream is, String savePath) write File To Disk try { OutputStream outputStream = new FileOutputStream(savePath); is.writeTo(outputStream); } catch (Exception e) { return false; return true; |
void | writeFileToDisk(File file, String targetPath) write File To Disk FileInputStream fis = null; FileOutputStream fos = null; try { fis = new FileInputStream(file); fos = new FileOutputStream(targetPath); byte[] b = new byte[1]; while (fis.read(b) != -1) { fos.write(b); ... |
void | writeFileToFile(File inFile, File toFile) write File To File OutputStream os = null; InputStream is = null; try { is = new FileInputStream(inFile); os = new FileOutputStream(toFile); byte[] buffer = new byte[4096]; for (int n; (n = is.read(buffer)) != -1;) { os.write(buffer, 0, n); ... |
void | writeFileToOutputStream(ZipInputStream zipInputStream, File outputFile) Writes a ZipInputStream to a File .
FileOutputStream fileOutputStream = new FileOutputStream(outputFile); try { writeInputStreamToOutputStream(zipInputStream, fileOutputStream); } finally { try { fileOutputStream.close(); } catch (Throwable ignore) { |
void | writeFileUTF8(final File file, final String contents) Write the contents of the string out to a file in UTF-8 format. final Writer writer = new OutputStreamWriter(new FileOutputStream(file), UTF8); try { writer.write(contents); } finally { writer.close(); |
void | writeFileWithParent(File file, String contentStr, String charset) write File With Parent write(file, contentStr, charset); |
void | writeFileWithParent(String filename, byte[] content) write File With Parent File file = new File(filename); File parent = file.getParentFile(); if (!parent.exists()) { parent.mkdirs(); FileOutputStream fos = new FileOutputStream(file); fos.write(content); fos.close(); ... |