从文件得到ByteArrayOutputStream

public static ByteArrayOutputStream getOutputStream(String filePath){
		
		File file = new File(filePath);
		FileInputStream in = null;
		ByteArrayOutputStream out = new ByteArrayOutputStream();
		try {
			in = new FileInputStream(file);
			byte[] buffer = new byte[in.available()];
			in.read(buffer);
			out.write(buffer);
			
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			try {
				if(in!=null) in.close();
			} catch (Exception e2) {
			}
			
		}
		return out;
	}

猜你喜欢

转载自panyongzheng.iteye.com/blog/1343762
今日推荐