A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 心弦上的景致 中级黑马   /  2013-4-9 15:23  /  1727 人查看  /  7 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

本帖最后由 心弦上的景致 于 2013-4-10 12:23 编辑

  1. import java.io.*;

  2. public class Inttt {

  3. public static void main(String[] args) {
  4.   String name1="F:\\我的文档\\123.jpg";
  5.   String name2="F:\\我的文档\\555.jpg";
  6.   try {
  7.    BufferedInputStream in = new BufferedInputStream(
  8.      new FileInputStream(name1));
  9.    BufferedOutputStream out = new BufferedOutputStream(
  10.      new FileOutputStream(name2));
  11.    int buffer = 8192;
  12.    byte[] bt = new byte[buffer];
  13.    int read;
  14.    if (in != null) {
  15.     while (true) {
  16.      if ((read = in.read(bt,0,bt.length)) != -1) {
  17.       out.write(bt,0,read);
  18.      }else{
  19.       break;
  20.      }
  21.     }
  22.    }
  23.    in.close();
  24.   } catch (Exception e) {

  25.   }

  26. }

  27. }
复制代码

评分

参与人数 1技术分 +1 收起 理由
陈丽莉 + 1

查看全部评分

7 个回复

倒序浏览
郭彦君 发表于 2013-4-9 15:26
不能用中文做为目录名

嗯 这个细节被我忽略了 ,但是编译报错误 不是中文目录导致的。
回复 使用道具 举报
yufeng47 发表于 2013-4-9 15:36
我这可以运行啊,没问题啊,除了没有关闭输出流

这都被你发现了 好样的。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马