System.out.print(s2);写到main方法外面去了
放在}前面就可以了。

解决方案 »

  1.   

    import java.io.*;
    public class test {
      // Throw exceptions to console:
      public static void main(String[] args) throws IOException {
        // 1. Reading input by lines:
        BufferedReader in = new BufferedReader(new FileReader("test.java"));
        String s, s2 = new String();
        while((s = in.readLine())!= null) {
          s2+= s + "\n";
        }
        in.close();
        System.out.print(s2);
      }
    }
      

  2.   

    System.out.print(s2);
    写到main函数外面了,改成
        in.close();
        System.out.print(s2);
        }
    }