import java.io.*;
class pw{
public static void main(String args[]){
try{
String s = "Hello";
PrintWriter pw = new PrintWriter("x.txt");
if(true)
pw.printf("%s%s",s," World!");
}catch(Exception e){}
}
}
pw.printf("%s%s",s," World!"); 如果把这个放在 while 外面 就可以, 放里面就提示没声明。 但是我又必需把这个 PrintWriter pw 放外面, 因为除了这个 if () 里面还有好多条件判断, 我不可能在每个里面都声明一个 PrintWriter pw 吧。。。