import java.io.*;
public class TestFile {
public static void main(String[] args) {
int b,c;
byte[] buffer = new byte[100];
File f = new File("G:\\com.gknl");
File fTemp = null;
try {
fTemp=File.createTempFile("letter",".txt",f);
System.out.println("输入一行文本,并存入磁盘:");
b = System.in.read(buffer);
FileOutputStream writeFile = new FileOutputStream(fTemp);
writeFile.write(buffer,0,b);
FileInputStream In = new FileInputStream(fTemp);
FileOutputStream Out = new FileOutputStream("G:\\com.gknl\\line.txt");
while((c=In.read())!=-1){
Out.write(c);
}
In.close();
fTemp.deleteOnExit();
System.out.println("输入完毕!!");
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
[此贴子已经被作者于2007-7-31 16:53:49编辑过]