import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;public class Text { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub try { FileOutputStream out =new FileOutputStream("FileName.txt"); out.write("字符串写入文件".getBytes()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }}