import java.io.*;
public class 拷贝
{
public static void main(String[] args)
{
String[] str = {"123456"};
File fid = new File("D\\a.txt"); //创建地址,
File did = new File("D\\b.txt");
FileWriter fod = null; //创建文件写入对象
FileReader dod = null; //创建文件读取对象
if ( fid.exists() )
{
System.out.println("文件已经存在");
}
else
{
try
{
fid.createNewFile();
System.out.println("文件创建成功");
} catch (Exception e)
{
}
}
try
{
fod = new FileWriter("D\\\\a.txt");
for (int i=0; i<str.length; i++)
{
fod.write(str[i]);
}
} catch (Exception e)
{
}
finally
{
try
{
fod.close();
} catch (IOException e2)
{
}
}
try
{
dod = new FileReader(fid);
String ctr = null;
while ( (ctr = dod.read() ) != null )
{
System.out.println(ctr);
}
} catch (Exception e)
{
// TODO: handle exception
} finally
{
try
{
dod.close();
} catch (Exception e2)
{
// TODO: handle exception
}
}
}
}

JAVA拷贝为什么编译会报错啊?
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
4条回答 默认 最新
- I'Msohs 2021-11-15 16:46关注
这么多try catch ,还不如直接抛一个大个的异常
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报