i 绝望

依然

Miss Lang

java代码I/O类

总结:流类无法理解啊——————

package com.aini;

import java.io.*;
//流类
//使用FileInputStream读取文件信息 

public class ffg {// 这个byte真的是个字节方法。。。一个不能错
	public static byte[] readFileByFileInputStream(File file)
			throws IOException {
		ByteArrayOutputStream oot = new ByteArrayOutputStream();
		FileInputStream fis = null;
		try {
			fis = new FileInputStream(file);
			byte[] b = new byte[4];
			int i = 0;// 这个??
			while ((i = fis.read(b, 0, b.length)) != -1) {
				oot.write(b, 0, i);// 缓冲区写入数据
			}

		} catch (Exception E) {
			System.out.println("Error occurs during reading"
					+ file.getAbsoluteFile());
		} finally {
			if (fis != null)
				fis.close();
			if (oot != null)
				oot.close();

		}

		return oot.toByteArray();
	}
}

  

posted on 2013-11-10 21:15  juewang  阅读(215)  评论(0编辑  收藏  举报

绝望依然

Miss Lang