import java.io.*;
public class PrintStreamDemo
{
public static void main(String[] args)throws IOException
{
try
{
FileInputStream fis = new FileInputStream (FileDescriptor.in);//指定输入流为键盘
PrintStream ps = new PrintStream (new FileOutputStream ("D://testfile//file.log"), true);
int is;
while ((is=fis.read()) != -1)ps.println((char)is);
fis.close();
ps.close();
}
catch(FileNotFoundException e)
{
System.out.println(e);
}
catch(IOException e)
{
System.out.println(e);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
评论