- <div class="blockcode"><blockquote>import java.io.*;
- public class IOLX2 {
- public static void main(String[] ages)throws IOException
- {
- copy_2();
- }
- public static void copy_2()
- {
- FileReader fr = null;
- FileWriter fw = null;
- try
- {
- fw = new FileWriter("D:\\abcddddddde2.txt");
- fr = new FileReader ("IOLX.java");
- char[] buff = new char[1024];
- int len=0;
- while((len=fr.read(buff))!=-1)
- {
- fw.write(buff,0,len);
- }
- }
- catch(IOException e){throw new RuntimeException("读写失败");}
- finally
- {
- if(fw!=null)
- {
- try
- {
- fw.close();
- }
-
- catch(IOException e){throw new RuntimeException("路径不正确");}}
- if(fr!=null)
- {
- try
- {
- fr.close();
- }
-
- catch(IOException e)
- {throw new RuntimeException("没有这个文件");}
- }}
- }
- }
- /*这个是在EditPlus 3中的代码*/
复制代码
import java.io.*;
public class IOLX3 {
public static void main(String[] ages)throws IOException
{
copy_2();
}
public static void copy_2()
{
FileReader fr = null;
FileWriter fw = null;
try
{
fw = new FileWriter("D:\\abcddddddde2.txt");
fr = new FileReader ("IOLX.java");
char[] buff = new char[1024];
int len=0;
while((len=fr.read(buff))!=-1)
{
fw.write(buff,0,len);
}
}
catch(IOException e){throw new RuntimeException("读写失败");}
finally
{
if(fw!=null)
{
try
{
fw.close();
}
catch(IOException e){throw new RuntimeException("路径不正确");}}
if(fr!=null)
{
try
{
fr.close();
}
catch(IOException e)
{throw new RuntimeException("没有这个文件");}
}}
}
}
/*这个是在MyEclipse中的*/
我发现一个比较严重的问题 在MyEclipse 中写的代码和在EditPlus 3中写的代码不一样 我在EditPlus 3中能运行粘贴复制到MyEclipse中就运行不了 这是为何
而且路径是相同的
|
|