import java.io.*;
class Txtcopy
{
public static void main(String args[])
{
byte[] b1 = new byte[255];
byte[] b2 = new byte[255];
byte[] b3 = new byte[2056];
byte[] b4 = new byte[2056];
try
{
System.out.println("\n 请输入源文件名称:\n");
System.in.read(b1,0,255);
System.out.println("\n 请输入目的文件名称:\n");
System.in.read(b2,0,255);
String sourceName = new String(b2,0);
String desName = new String(b1,0);
FileInputStream fileInput = new FileInputStream(sourceName);
int bytes1 = fileInput.read(b3,0,2056);
String sourceFile = new String(b3,0,0,bytes1);
FileOutputStream FileOutput = new FileOutputStream(desName);
FileOutput.write(b3,0,bytes1);
fileInput = new FileInputStream(desName);
int bytes2 = fileInput.read(b4,0,2056);
String desFile = new String(b4,0,0,bytes2);
System.out.println("\n源文件内容为:\n");
System.out.println(sourceFile);
System.out.println("\n目的文件内容为:\n");
System.out.println(desFile);
}catch(Exception e)
{
System.out.println(e.toString());
}
}
}在里面输入:
C:\\test.txt
C:\\tt.txt
会出现:java.io.FileNotFoundException:c:\\tt.txt
怎么回事?