Java examples for java.io:File Extension Name
text file write
//package com.java2s; import java.io.PrintWriter; public class Main { public static void main(String[] argv) throws Exception { String path = "java2s.com"; String data = "java2s.com"; System.out.println(file_write(path, data)); }/*from w ww . j a va 2s .c o m*/ public static boolean file_write(String path, String data) { return file_write(path, data, "UTF-8"); } public static boolean file_write(String path, String data, String encoding) { try { PrintWriter writer = new PrintWriter(path, encoding); writer.print(data); writer.close(); return true; } catch (Exception e) { return false; } } }