List of utility methods to do Byte Array Save to File
void | copy(byte[] input, OutputStream output) Copy bytes from a byte[] to an OutputStream .
output.write(input); |
void | copy(byte[] input, Writer output) Copy and convert bytes from a byte[] to chars on a Writer .
ByteArrayInputStream in = new ByteArrayInputStream(input);
copy(in, output);
|
void | copy(byte[] input, Writer output, String encoding) Copy and convert bytes from a byte[] to chars on a Writer , using the specified encoding.
ByteArrayInputStream in = new ByteArrayInputStream(input);
copy(in, output, encoding);
|
void | saveBytes(@NotNull File file, @NotNull byte[] bytes) Saves the contents of a byte[] to the specified File .
FileOutputStream stream = null; try { stream = new FileOutputStream(file); stream.write(bytes); } finally { if (stream != null) { stream.close(); |
void | saveFile(byte[] data, String fileName) save File if (!DESTINY_DIR.exists() && !DESTINY_DIR.mkdirs()) { return; File mainPicture = new File(DESTINY_DIR, fileName); try { FileOutputStream fos = new FileOutputStream(mainPicture); fos.write(data); fos.close(); ... |
void | writeBytes(File file, boolean append, byte[] bytes) write bytes into file if (bytes.length == 0) return; FileOutputStream output = new FileOutputStream(file, append); output.write(bytes); output.flush(); output.close(); |
void | writeBytes(byte[] bytes, File file, boolean append) Writes bytes into file. Check.arg().notNull(bytes); Check.arg().notNull(file); if (file.isDirectory()) throw new IllegalArgumentException("file = " + file.getPath() + " refers to directory, not a normal text file"); OutputStream out = null; try { out = new FileOutputStream(file, append); ... |
void | writeFile(String fileName, byte[] content) write File try { FileOutputStream fos = new FileOutputStream(fileName); fos.write(content); fos.flush(); fos.close(); } catch (Exception e) { |
File | writeFile(String fileName, byte[] datas, boolean overwrite) write File File file = new File(fileName); if (file.exists()) { if (!overwrite) { fileName = Math.random() + fileName; file = new File(fileName); } else { file.delete(); file.createNewFile(); FileOutputStream fos = new FileOutputStream(fileName); fos.write(datas); fos.close(); return file; |
File | writeFile(String path, String fileName, byte[] datas, boolean overwrite) Write a file to disk File file = new File(path); if (!file.exists() || !file.isDirectory()) { file.mkdirs(); if (!path.endsWith(File.separator)) { path += File.separator; file = new File(path + fileName); ... |