游戏一下:写一个程序,打印程序自己的内容。

z_lping 2007-01-09 12:44:37
:)
...全文
575 24 打赏 收藏 转发到动态 举报
写回复
用AI写文章
24 条回复
切换为时间正序
请发表友善的回复…
发表回复
jihanzhong 2007-11-02
  • 打赏
  • 举报
回复
调用反编译工具,或者其他办法,反编译本身,然后用io写出,不过格式肯定不一致了
  • 打赏
  • 举报
回复
但是这个能运行吗?

' 在 Java 里可以用这个吗?
z_lping 2007-11-02
  • 打赏
  • 举报
回复
怎么又给挖出来了呀,哈哈……
梅小西Echo 2007-11-02
  • 打赏
  • 举报
回复
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));}}
uaudy 2007-11-02
  • 打赏
  • 举报
回复
似乎明白了意思,刚刚还在看API里的string啊,呵呵
「已注销」 2007-11-02
  • 打赏
  • 举报
回复
这个老早的了,现在的程序员忙着赚钱,谁有空研究这个破玩意
huangxw000 2007-11-02
  • 打赏
  • 举报
回复
新手,解决不了,不过楼主的提问很有创意..
z_lping 2007-01-12
  • 打赏
  • 举报
回复
自己写个吧。
-----------------------------------------------------
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));}}

-----------------------------------------------------------------------------
溺水的鱼 2007-01-12
  • 打赏
  • 举报
回复
运行了才知道!高啊!
z_lping 2007-01-12
  • 打赏
  • 举报
回复
运行一下看看嘛。
大头贼 2007-01-12
  • 打赏
  • 举报
回复
楼主想干啥?自省?
溺水的鱼 2007-01-12
  • 打赏
  • 举报
回复
死循环??打印语句也是你程序的内容,你怎么把这个打印语句打出来呢?
luyang1016 2007-01-09
  • 打赏
  • 举报
回复
//: 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");
}
} ///:~
z_lping 2007-01-09
  • 打赏
  • 举报
回复
发现同志们的思维方向都差不多呀,首先想到的都是File I/O。下次俺写清楚点。:P
biaoflying 2007-01-09
  • 打赏
  • 举报
回复
终于看清楚楼主的意思了,好好想想
chenyifei211 2007-01-09
  • 打赏
  • 举报
回复
我感觉此问题不能实现,原因如下:
1.因为所写java代码是随机的,故此程序之内必须包含将所写代码保存在固定位置之内才可以调用打印
2.又因楼主不让此java文件存在固定的路径下以及采用固定的类明,故也不能实现文件的读入写出,小弟愚笨,实在想不出有什么办法实现
等高人出现,帮你顶!
chilina 2007-01-09
  • 打赏
  • 举报
回复
无聊
z_lping 2007-01-09
  • 打赏
  • 举报
回复
俺无语了,怎么……难道俺写的就那么难懂???
biaoflying 2007-01-09
  • 打赏
  • 举报
回复
PrintWriter pw=new PrintWriter(System.out);
关键的一行。。。。。
biaoflying 2007-01-09
  • 打赏
  • 举报
回复
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();
}
}
加载更多回复(4)

62,630

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧