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:");
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:\\line.txt");
while((c=In.read())!=-1){
Out.write(c);
}
// File g = new File("G:\\line.txt");
Out.flush();
In.close();
Out.close();
System.out.println(fTemp.getAbsolutePath());
fTemp.deleteOnExit();
System.out.println("输入完毕!!");
} catch (IOException e1) {
e1.printStackTrace();
}
}
}