如果不写try catch就会出现unhandled exception filenotfoundexception这个错误 import java.io.FileOutputStream; public class test { public static void main(String args[ ]) { String s="123456"; byte b[]=s.getBytes(); try { FileOutputStream f = new FileOutputStream("out.txt"); f.write(b); f.flush( ); f.close( ); } catch(Exception e) { } } }