- <div class="blockcode"><blockquote>import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- public class ZiJia
- {
- public static void main(String args[]) throws IOException
- {
- FileOutputStream fo = null;
- FileInputStream fi = null;
- try
- {
- fo = new FileOutputStream("e:\\2.pang");
- fi = new FileInputStream("e:\\1.pang");
- byte[] a = new byte[1024];
- int k = -1;
- while ((k = fi.read(a)) != -1)
- {
- fo.write(a, 0, k);
- }
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- finally
- {
- try
- {
- if (fi != null)
- fi.close();
- if (fo != null)
- fo.close();
- }
- catch (IOException e)
- {
- throw new RuntimeException(e.toString());
- }
- }
- }
复制代码
没什么问题啊, 这是我在myeclipse中运行的图是结果 。 是不是你的包导错了 ? |
-
木.jpg
(21.98 KB, 下载次数: 7)
|