zoukankan      html  css  js  c++  java
  • 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();
    	}
    }
    

      

  • 相关阅读:
    Git Bash关键命令
    一个不需要Log4Net的写日志的简单方法
    未知软件
    Linux
    Linux
    Linux
    Linux
    Linux
    Linux
    Linux
  • 原文地址:https://www.cnblogs.com/langlove/p/3417088.html
Copyright © 2011-2022 走看看