把out定义在外面
public static void main(String args[]){
File f;
OutputStream out;
f=new File("e:"+File.separator+"test.doc");
try{
out=new FileOutputStream(f);
}
catch(FileNotFoundException e){
e.printStackTrace();
}
String str="asdfasdfasdf";
byte b[]=str.getBytes();
try{
out.write(b);}
catch(IOException e){
e.printStackTrace();
}
out.close();
}