List of utility methods to do FileOutputStream Create
void | writeFileByChar(String content, String filename, String encoding) write File By Char File file = new File(filename); Writer writer = null; try { if (null == encoding || "".equals(encoding)) { writer = new OutputStreamWriter(new FileOutputStream(file)); } else { writer = new OutputStreamWriter(new FileOutputStream(file), encoding); writer.write(content); } catch (Exception e) { e.printStackTrace(); } finally { if (writer != null) { try { writer.close(); } catch (Exception e1) { e1.printStackTrace(); |
void | writeFileByLine(String content, String filename, boolean append) write File By Line File file = new File(filename); String pathname = new File(filename).getParent(); if (!new File(pathname).exists()) { new File(pathname).mkdirs(); PrintWriter writer = null; try { writer = new PrintWriter(new FileOutputStream(file, append)); ... |
void | writeFileBytes(File pFile, byte[] pBytes) Writes the byte array into the specified file. if (pBytes == null) pBytes = new byte[0]; FileOutputStream fos = null; try { fos = new FileOutputStream(pFile); fos.write(pBytes); } catch (IOException e) { throw e; ... |
void | writeFileContent(String filepath, byte[] content) Write content into a file. writeFileContent(new File(filepath), content);
|
void | writeFileContent(String sFileName, byte[] content) write File Content if (sFileName == null) { throw new IllegalArgumentException("FileName argument is null"); if (content == null) { throw new IllegalArgumentException("Content argument is null"); FileOutputStream fos = null; try { ... |
void | writeFileCover(String path, String content) write File Cover File file = new File(path); if (!file.exists()) { file.createNewFile(); FileOutputStream outputStream = new FileOutputStream(file, false); outputStream.write(content.getBytes("utf-8")); outputStream.close(); |
void | writeFileData(File dataFile, String targetFile) write File Data FileInputStream istream = new FileInputStream(dataFile); FileOutputStream ostream = new FileOutputStream(targetFile); byte[] buffer = new byte[1024]; int len = 0; while ((len = istream.read(buffer)) != -1) { ostream.write(buffer, 0, len); istream.close(); ... |
void | writeFileData(File file, byte[] fileData) Writes the specified data to the specified fie BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file)); bos.write(fileData); bos.close(); |
void | writeFileFromBytes(byte[] bytes, File file) write File From Bytes OutputStream os = new FileOutputStream(file); long length = bytes.length; os.write(bytes); os.close(); return; |
int | writeFileFromStream(File tempFile, InputStream in) write File From Stream byte[] buffer = new byte[1024]; BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(tempFile)); BufferedInputStream bin = new BufferedInputStream(in); int bytesRead = 0; int bytesTotal = 0; while ((bytesRead = bin.read(buffer)) != -1) { out.write(buffer, 0, bytesRead); bytesTotal += bytesRead; ... |