List of utility methods to do File Object Create
File | toFile(JavaFileObject javaFileObject) Gets the file from a Java file object. return new File(javaFileObject.getName()); |
List | toFile(List to File List<File> files = new ArrayList<File>(); for (String filename : filenames) { files.add(new File(filename)); return files; |
void | toFile(Map to File int c = 0; try (PrintWriter writer = new PrintWriter(output, "UTF-8")) { for (Map.Entry<K, V> e : res.entrySet()) { writer.println(c + "\t" + e.getKey().toString() + "\t" + e.getValue().toString()); c++; |
void | toFile(String base64Code, String targetPath) to File byte[] buffer = base64Code.getBytes(); FileOutputStream out = new FileOutputStream(targetPath); out.write(buffer); out.close(); |
void | toFile(String content, File output) to File try { BufferedWriter writer = new BufferedWriter(new FileWriter(output)); writer.write(content); writer.flush(); writer.close(); } catch (IOException e) { throw new RuntimeException(e); |
void | toFile(String context, String fileName, boolean append) Writes desired string data to appropriate file. PrintStream ps = new PrintStream(new FileOutputStream(fileName, append)); ps.println(context); ps.flush(); ps.close(); |
File | toFile(String fileName) to File try { return new File(fileName).getCanonicalFile(); } catch (IOException e) { return new File(fileName).getAbsoluteFile(); |
void | toFile(String fileName, String content) to File File file = new File(fileName); try (BufferedWriter bw = new BufferedWriter(new FileWriter(file))) { bw.write(content); bw.flush(); |
File | toFile(String fileName, String cwd) to File File file = new File(fileName); if (!file.isAbsolute()) { file = new File(cwd + File.separator + fileName); return file; |
void | toFile(String fileName, String txt) Write string to file PrintWriter pw = new PrintWriter(new FileWriter(fileName)); pw.print(txt); pw.close(); |