日期:2014-05-20 浏览次数:20802 次
import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; public class D316 {// 有问题 public static void main(String[] args) { try { FileInputStream fileinputstream = new FileInputStream(new File("C:"+File.separator+"a.txt"));//这里有问题 InputStreamReader inputstreamreader = new InputStreamReader( fileinputstream); FileOutputStream fileoutputstream = new FileOutputStream(new File( "C:"+File.separator+"b.txt"));//还有这里 OutputStreamWriter outputstreamwriter = new OutputStreamWriter( fileoutputstream); int ch; while ((ch = inputstreamreader.read()) != -1) { System.out.print((char)ch + " "); outputstreamwriter.write(ch); } inputstreamreader.close(); outputstreamwriter.close(); } catch (IOException e) { e.printStackTrace(); } } }
------解决方案--------------------
ava.io.FileNotFoundException: C:\a.txt (系统找不到指定的文件。)
这个是个文件Copy程序,你的源文件c:\a.txt必须存在,先用编辑器(如记事本)在C:\建一个a.txt程序就可以了