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

首頁 > 學院 > 開發設計 > 正文

java字符流字節流復制文件

2019-11-14 10:48:09
字體:
來源:轉載
供稿:網友

一、通過字符流復制文件

import java.io.*; public class Test { public static void main(String args[]) throws IOException{ File f1 = new File("e:/java/code/"); f1.mkdirs(); File f2 = new File(f1,"aa.txt"); f2.createNewFile(); int n; FileReader in = new FileReader("e:/java/code/aa.txt"); FileWriter ci = new FileWriter("e:/java/code/copy.txt"); while((n=in.read())!=-1) { ci.write(n); System.out.PRint((char)n); } in.close(); ci.close(); } }

二、通過字節流復制文件

import java.io.*; public class Test1 { public static void main(String args[]) throws IOException{ File f1 = new File("e:/a/b"); f1.mkdirs(); File f2 = new File(f1,"aa.jpg"); f2.createNewFile(); int n; InputStream in = new FileInputStream("e:/java/code/aa.jpg"); OutputStream ci = new FileOutputStream("e:/java/code/copy.jpg"); while((n=in.read())!=-1) { ci.write(n); } in.close(); ci.close(); } }


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 长子县| 长乐市| 鄂伦春自治旗| 任丘市| 呼伦贝尔市| 澄迈县| 军事| 玉环县| 壶关县| 资中县| 会宁县| 西林县| 昭通市| 金阳县| 阳朔县| 平昌县| 泗阳县| 资溪县| 定西市| 慈利县| 永新县| 卓尼县| 泰州市| 冕宁县| 石阡县| 册亨县| 大邑县| 临颍县| 丹巴县| 夏邑县| 渝中区| 工布江达县| 衡阳县| 漯河市| 密山市| 衡南县| 汕尾市| 应城市| 县级市| 武功县| 康定县|