国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

[JAVA100例]033、讀寫文件(字節(jié))

2019-11-18 15:58:38
字體:
供稿:網(wǎng)友

import java.io.*;
/**
 * <p>Title: 讀取和寫入文件</p>
 * <p>Description: 使用字節(jié)流方式操作文件,讀取和寫入文件。</p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Filename: CopyBytes.java</p>
 * @version 1.0
 */
public class CopyBytes {
/**
 *<br>方法說明:主方法
 *<br>輸入?yún)?shù):
 *<br>返回類型:
 */
    public static void main(String[] args) throws IOException {
        String sFile;
        String oFile;
        if(args.length<2){
          System.out.          return;
        }else{
          sFile = args[0];
          oFile = args[1];
        }
        try{
          File inputFile = new File(sFile);//定義讀取源文件
          File outputFile = new File(oFile);//定義拷貝目標(biāo)文件
          //定義輸入文件流
          FileInputStream in = new FileInputStream(inputFile);
          //將文件輸入流構(gòu)造到緩存
          BufferedInputStream bin = new BufferedInputStream(in);
          //定義輸出文件流
          FileOutputStream out = new FileOutputStream(outputFile);
          //將輸出文件流構(gòu)造到緩存
          BufferedOutputStream bout = new BufferedOutputStream(out);
          int c;
          //循環(huán)讀取文件和寫入文件
          while ((c = bin.read()) != -1)
             bout.write(c);
          //關(guān)閉輸入輸出流,釋放資源
          bin.close();
          bout.close();
        }catch(IOException e){
          //文件操作,捕捉IO異常。
          System.err.println(e);
        }
    }
}




發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 洞口县| 韶关市| 浠水县| 和田市| 泗水县| 辽宁省| 武城县| 清徐县| 定边县| 左权县| 通河县| 奉新县| 紫阳县| 昌乐县| 广饶县| 章丘市| 崇仁县| 深水埗区| 黎城县| 阿合奇县| 历史| 上犹县| 镇赉县| 岳阳市| 泽普县| 逊克县| 连州市| 乌兰浩特市| 曲阳县| 辽宁省| 石门县| 金塔县| 河北区| 高州市| 简阳市| 额尔古纳市| 宜兰市| 宜兰市| 志丹县| 志丹县| 巴楚县|