:)
解决方案 »
- java的一个ZIP解压问题求解。
- 求助,swing中JTextArea的内容怎么一行一行读出来?
- 如何正确在for循环里的if语句中,写个break?
- 里面的测试小程序为什么会报错:java.lang.IllegalThreadStateException
- 同志们,请问throws和try-catch块的区别?
- 在数据库应用中,多线程须不需要考虑同步问题,急!谢谢
- 谁能帮忙推荐几个关于Java的论坛?
- 在Jbuilder6.0中,如何用CORBA开发数据库APP!
- 王森的Kjava一书中Database类在哪个jdk中??急
- 我真的不活了
- 关于车辆监控定位的问题
- 初学中遇到的小问题,请各位帮下忙?谢谢啦~
// 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");
}
} ///:~
{
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();
}
}
关键的一行。。
1.因为所写java代码是随机的,故此程序之内必须包含将所写代码保存在固定位置之内才可以调用打印
2.又因楼主不让此java文件存在固定的路径下以及采用固定的类明,故也不能实现文件的读入写出,小弟愚笨,实在想不出有什么办法实现
等高人出现,帮你顶!
-----------------------------------------------------
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));}}-----------------------------------------------------------------------------
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));}}