- <P>import java.io.*;
- public class a {
- public static void main(String[] args) throws IOException
- {
- copy();
- }
- public static void copy()
- {
- BufferedInputStream bufis=null;
- BufferedOutputStream bufos=null;
- try
- {
- bufis=new BufferedInputStream(new FileInputStream("c:\\Damea.java"));
- bufos=new BufferedOutputStream(new FileOutputStream("d:\\Damea.java"));
- int by=0;
- while((by=bufis.read())!=-1)
- {
- bufos.write(by);
- }
- }
- catch(IOException e)
- {
- throw new RuntimeException("复制文件失败");
- }
- finally
- {
- try
- {
- if(bufis!=null)
- bufis.close();
- }
- catch(IOException e)
- {
- throw new RuntimeException("读取关闭失败");
- }
- try
- {
- if(bufos!=null)
- bufos.close();
- }
- catch(IOException e)
- {
- throw new RuntimeException("写入关闭失败");
- }
- }
-
-
- }</P>
- <P>}
- </P>
复制代码 为什么总是复制失败,图片就就能复制,文本复制不了
|