:)

解决方案 »

  1.   

    //: c11:TestEOF.java
    // Testing for the end of file
    // while reading a byte at a time.
    // From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
    // www.BruceEckel.com. See copyright notice in CopyRight.txt.
    package c11;
    import com.bruceeckel.simpletest.*;
    import java.io.*;public class TestEOF {
      static Test monitor = new Test();
      // Throw exceptions to console:
      public static void main(String[] args)
      throws IOException {
        DataInputStream in =
          new DataInputStream(
           new BufferedInputStream(
            new FileInputStream("F:\\javaTestPrj\\src\\c11\\TestEOF.java")));
        while(in.available() != 0) {
          System.out.print((char)in.readByte());
        }
        monitor.expect("F:\\javaTestPrj\\src\\c11\\TestEOF.out");
      }
    } ///:~
      

  2.   

    都编译成class了,哪来的程序自己的内容?除非写个反编译的程序
      

  3.   

    哎,这么着吧,写一个Java源文件,运行的时候打印出来的内容跟这个源文件一样。
      

  4.   

    import java.io.*;public class Print
    {
    public static void main(String[] args)throws IOException{
    BufferedReader br=new BufferedReader(new FileReader("1.txt"));
    String s=null;
    PrintWriter pw=new PrintWriter(System.out);
    while((s=br.readLine())!=null){
    pw.println(s);
    }
    pw.close();
    }
    }
      

  5.   

    PrintWriter pw=new PrintWriter(System.out);
    关键的一行。。
      

  6.   

    我感觉此问题不能实现,原因如下:
    1.因为所写java代码是随机的,故此程序之内必须包含将所写代码保存在固定位置之内才可以调用打印
    2.又因楼主不让此java文件存在固定的路径下以及采用固定的类明,故也不能实现文件的读入写出,小弟愚笨,实在想不出有什么办法实现
    等高人出现,帮你顶!
      

  7.   

    发现同志们的思维方向都差不多呀,首先想到的都是File I/O。下次俺写清楚点。:P
      

  8.   

    自己写个吧。
    -----------------------------------------------------
    class S{public static void main(String[]a){String s="class S{public static void main(String[]a){String s=;char c='';System.out.println(s.substring(0,52)+c+s+c+s.substring(52,61)+c+s.substring(61));}}";char c='"';System.out.println(s.substring(0,52)+c+s+c+s.substring(52,61)+c+s.substring(61));}}-----------------------------------------------------------------------------
      

  9.   

    但是这个能运行吗?' 在 Java 里可以用这个吗?
      

  10.   

    似乎明白了意思,刚刚还在看API里的string啊,呵呵
      

  11.   

    class   S{
    public   static   void   main(String[]a){
    String   s= "class   S{public   static   void   main(String[]a){
    String   s=;char   c= ' '
    ;System.out.println(s.substring(0,52)+c+s+c+s.substring(52,61)+c+s.substring(61));}} ";
    char   c= ' " ';
    System.out.println(s.substring(0,52)+c+s+c+s.substring(52,61)+c+s.substring(61));}}