文件流转换成字节数组

			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			byte[] b = new byte[1024];
			int i = 0;
			InputStream is = new FileInputStream(upload);
			while((i = is.read(b)) != -1){
				baos.write(b, 0, i);
			}
			byte[] b1 = baos.toByteArray();

 

你可能感兴趣的:(java,文件流转换成字节数组)