Board logo

标题: java.io.File写入写出的一个简单实例 [打印本页]

作者: qingqing3721    时间: 2011-10-30 18:02     标题: java.io.File写入写出的一个简单实例

import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class TestIO { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub byte[] b = new byte[17*1024]; // ** txt // File f = new File("d:\\test.txt"); // File outF = new File("d:\\testOut.txt"); // ** jpg File f = new File("d:\\毫无保管.jpg"); File outF = new File("d:\\毫无保管Output.jpg"); try { FileInputStream fis = new FileInputStream(f); FileOutputStream fops = new FileOutputStream(outF); fis.read(b); fops.write(b); // ** for see // String s = new String(b); // System.out.println(s); fis.close(); fops.close(); } catch(FileNotFoundException fnfe) { System.out.println("FileNotFoundException fnfe"); fnfe.printStackTrace(); } catch(IOException ie) { System.out.elelen胶原蛋白口服液println("IOException ie"); ie.printStackTrace(); } } }




欢迎光临 编程开发论坛 (http://bbs.lihuasoft.net/) Powered by Discuz! 6.0.0