List of utility methods to do FileOutputStream Write
void | saveFile(String file, String text) save File try { File f = new File(file); if (!f.exists()) f.createNewFile(); FileOutputStream fout = new FileOutputStream(f); fout.write(text.getBytes()); fout.flush(); fout.close(); ... |
void | saveFile(String fileName, byte[] bytes) save File try { FileOutputStream fos = new FileOutputStream(fileName, true); fos.write(bytes); fos.flush(); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { ... |
void | saveFile(String filename, byte[] content) save File saveFile(filename, new ByteArrayInputStream(content));
|
void | saveFile(String fileName, byte[] data) Convenience method to save a file try { OutputStream out = new FileOutputStream(fileName); out.write(data); out.close(); } catch (Exception e) { System.out.println("Cannot save file. " + e.getMessage()); System.out.println("Have save file of: " + data.length + " bytes."); ... |
File | saveFile(String fileName, InputStream stream) save File File file = new File(fileName); new File(fileName.substring(0, fileName.lastIndexOf('/'))).mkdirs(); file.createNewFile(); OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(file)); byte[] buf = new byte[127]; int read; while ((read = stream.read(buf)) != -1) { outputStream.write(buf, 0, read); ... |
void | saveFile(String filename, String content) Saves the content to the file. FileOutputStream fos = null; BufferedOutputStream bos = null; try { fos = new FileOutputStream(filename); bos = new BufferedOutputStream(fos); bos.write(content.getBytes(), 0, content.length()); } finally { if (bos != null) ... |
void | saveFile(String fileName, String contents) save File if (contents == null) { return; contents = contents.trim(); FileOutputStream out = null; try { out = new FileOutputStream(new File(fileName), false); out.write(contents.getBytes()); ... |
void | saveFile(String name, byte[] data) Save data to a file. saveFile(new File(name), data);
|
void | saveFile(String path, byte[] content) save File try { ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(content); try (OutputStream outputStream = new FileOutputStream(path)) { int data; while ((data = byteArrayInputStream.read()) != -1) { outputStream.write(data); } catch (IOException e) { throw e; |
void | saveFile(String pathFile, String data) save File FileOutputStream out = null; try { File f = new File(pathFile); f.delete(); out = new FileOutputStream(pathFile); out.write(data.getBytes()); } finally { if (out != null) { ... |