本帖最后由 yinbolove576 于 2013-4-12 16:40 编辑
import java.io.*;
public class Test7 {
public static void main(String[] args)
{
copyFile();
}
public static void copyFile()
{
BufferedReader bufr = null;
BufferedWriter bufw = null;
try
{
bufr = new BufferedReader(new FileReader("C:\\1.txt"));
bufw = new BufferedWriter(new FileWriter("C:\\CopyFile.txt"));
String line = null;
while((line=bufr.readLine())!=null)
{
bufw.write(line);
bufw.newLine();
bufw.flush();
}
}
catch(IOException e)
{
throw new RuntimeException("复制文件失败");
}
finally
{
try
{
if(bufr!=null)
bufr.close();
}
catch(IOException e)
{
throw new RuntimeException("读取文件失败");
}
try
{
if(bufw!=null)
bufw.close();
}
catch(IOException e)
{
throw new RuntimeException("写入文件失败");
}
}
}
}
程序能够正常编译,但是运行后却出现“Exception in thread "main" java.lang.NoClassDefFoundError: Test7 (wrong name: com/itheima/Test7)”异常,小弟刚学这些东东,估计是字节、字符流上有问题,但一时也不知道具体错哪儿了,往大侠们帮忙解决下,谢谢!
|