List of utility methods to do FileOutputStream Create
Boolean | writeFile(String path, byte[] contents) write File Boolean success = false; try { File outputfile = new File(path); FileOutputStream fos = new FileOutputStream(outputfile); fos.write(contents); fos.flush(); fos.close(); success = true; ... |
boolean | writeFile(String path, byte[] data) Write whole data to a file. OutputStream os = null; try { os = new FileOutputStream(path); os.write(data); } catch (IOException e) { return false; } finally { try { ... |
void | writeFile(String path, Properties store, String comment) Writes data of a Properties object to a properties file. checkNullReference(path, store); File file = new File(path); File topDir = file.getParentFile(); if (topDir != null && !topDir.exists()) { topDir.mkdirs(); FileOutputStream fos = new FileOutputStream(file); store.store(fos, comment); ... |
void | writeFile(ZipEntry entry, ZipFile zipFile, File file) write File if (!buildDirectory(file.getParentFile())) { throw new IOException("Could not create directory: " + file.getParentFile()); if (!entry.isDirectory()) { copyInputStream(zipFile.getInputStream(entry), new BufferedOutputStream(new FileOutputStream(file))); } else { if (!buildDirectory(file)) { throw new IOException("Could not create directory: " + file); ... |
String | writeFile0(File file, CharSequence content, Iterable> lines) write File PrintWriter out = null; try { out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); if (content != null) { out.print(content); } else { for (Object line : lines) { out.print(line); ... |
void | writeFileAsBytes(String fullPath, byte[] bytes) Write an array of bytes to a file. OutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(fullPath)); InputStream inputStream = new ByteArrayInputStream(bytes); int token = -1; while ((token = inputStream.read()) != -1) { bufferedOutputStream.write(token); bufferedOutputStream.flush(); bufferedOutputStream.close(); ... |
void | writeFileAsString(final File filePath, final String output, final String charset) write File As String final OutputStreamWriter osw = charset == null ? new OutputStreamWriter(new FileOutputStream(filePath, false)) : new OutputStreamWriter(new FileOutputStream(filePath, false), charset); osw.write(output); osw.flush(); osw.close(); |
void | writeFileAsString(String filename, String contents) Write a String to disk using the specified filename and the default encoding. writeFileAsString(filename, contents, null); |
void | writeFileBinary(String filename, byte[]... dataArrays) write File Binary DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(filename))); for (byte[] data : dataArrays) { dos.write(data); dos.flush(); dos.close(); |
void | writeFileByBytes(String content, String filename) write File By Bytes File file = new java.io.File(filename); OutputStream out = null; try { out = new FileOutputStream(file, true); byte[] bytes = content.getBytes(); out.write(bytes); } catch (Exception e) { e.printStackTrace(); ... |