List of utility methods to do Write String to File
void | writeFile(String fileName, String text, String characterEncoding) This will write a string to a file with the specified encoding FileOutputStream fos; byte[] buf = text.getBytes(characterEncoding); int numWritten; fos = new FileOutputStream(fileName); numWritten = 0; fos.write(buf, numWritten, buf.length); fos.close(); |
void | writeFile(String fileName, String textToSave) write File if (fileName == null) throw new IOException("filename is null"); if (textToSave == null) throw new IOException("textToSave is null"); FileWriter fw = new FileWriter(fileName); BufferedWriter bw = new BufferedWriter(fw); fw.write(textToSave); bw.close(); ... |
boolean | writeFile(String fileName, String[] contents) description writes the array of strings into the file name speecified BufferedWriter bufWriter = null; String line; boolean success = true; if (null == contents) { return false; try { bufWriter = new BufferedWriter(new FileWriter(fileName)); ... |
void | writeFile(String fileName, String[] lines) write File try { File fout = new File(fileName); FileOutputStream fos = new FileOutputStream(fout); OutputStreamWriter osw = new OutputStreamWriter(fos); for (String line : lines) { osw.write(line); osw.close(); ... |
void | writeFile(String filename, StringBuilder sb) write File BufferedWriter bw = new BufferedWriter(new FileWriter(new File(filename))); bw.write(sb.toString()); bw.close(); |
void | writeFile(String filePath, String content) write File File file = new File(filePath); synchronized (file) { FileOutputStream fos = new FileOutputStream(filePath); fos.write(content.getBytes("UTF-8")); fos.close(); |
void | writeFile(String filePath, String content) write File RandomAccessFile raf = new RandomAccessFile(new File(filePath), "rw"); raf.writeUTF(content); raf.close(); |
void | writeFile(String filePath, String content) Write content to file. try { FileOutputStream os = new FileOutputStream(filePath); FileDescriptor fd = os.getFD(); os.write(content.getBytes()); os.flush(); fd.sync(); } catch (IOException e) { e.printStackTrace(); ... |
void | writeFile(String filePath, String content) ananya.tools.utils.FileUtils method to write string content to a file writeFile(new File(filePath), content);
|
boolean | WriteFile(String filepath, String content) Write File File outputFile = new File(filepath); if (outputFile.exists()) { outputFile.delete(); File parentDirectory = outputFile.getParentFile(); if (parentDirectory != null && !parentDirectory.exists()) { parentDirectory.mkdirs(); BufferedWriter writer = null; try { writer = new BufferedWriter(new FileWriter(filepath)); writer.write(content); return true; } catch (Exception e) { e.printStackTrace(); } finally { if (writer != null) { try { writer.close(); } catch (IOException e) { return false; |