private byte[] input2byte(InputStream inStream)
throws IOException {
ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
byte[] buff = new byte[100];
int rc = 0;
while ((rc = inStream.read(buff, 0, 100)) > 0) {
swapStream.write(buff, 0, rc);
}
byte[] in2b = swapStream.toByteArray();
return in2b;
}
分享到:
相关推荐
Blob、InputStream、byte 互转
Drawable Bitmap InputStream byte[]相互转化工具类,单例模式
原理讲解-ServletInputStream.readLine(byte[] b, int off, int len) 方法原理讲解-ServletInputStream.readLine(byte[] b, int off, int len) 方法
此文档主要的内容是byte类型与各类型(String、boolean、int、inputStream等)之间的转化
NULL 博文链接:https://f543711700.iteye.com/blog/678519
byte[] inputBytes = new byte[inputStream.available()]; inputStream.read(inputBytes); inputStream.close(); // 创建PDF文档 Document document = new Document(); PdfWriter writer = PdfWriter....
byte[] cont = new byte[(int) file1.length()]; is.read(cont);// 读取文件 for (int i = 0; i ; i++) { System.out.print((char) cont[i]); } is.close();// 关闭文件 // 保存文件 ...
dbStat.setBinaryStream(2, inputStream, (int) file_i.length()); // 执行SQL dbStat.execute(); k++; } System.out.println(firstfiles[x].getName()+":"+k); n+=k; ...
根据库的作者和年龄,它可能使用byte[] , InputStream , ByteBuffer或ReadableByteChannel 。 如果字节表示字符串,则还需要担心String , Reader和CharSequence 。 记住如何在它们之间进行转换是一项不费力的...
字节流工具,将流另存为文件、InputStream 转为 byte、byte 转为 InputStream
很不错的噢 自己网上找的 还有byte和inputstream相互转换的方法
private static byte[] PostData(string serverURL, byte[] data, Hashtable parms) { System.Net.WebClient webClientObj = new System.Net.WebClient(); if (parms != null) { serverURL = serverURL + ...
public static byte[] readInputStream(InputStream inputStream) throws IOException { byte[] buffer = new byte[1024]; int len = 0; ByteArrayOutputStream bos = new ByteArrayOutputStream(); while (...
ByteArrayInputStream(byte[] buf, int offset, int length) 创建 ByteArrayInputStream,用byte 数组的第 off 个位置先后的 len 个位置buf 作为其缓冲区数组。 2)FileInputStream:FileInputStream的适配源是File...
读取返回的输入流中的数据,并将其中的数据转换为byte数组 使用InputStream 的read方法以及ByteArrayOutputStream的wirte方法 inputStream.read(buffer) outputStream.write(buffer, 0, len) outputStream....
image to pdf demo , inputStream to byte[]
inputStream2String, string2InputStream : inputStream 与 string 按编码互转 outputStream2String, string2OutputStream: outputStream 与 string 按编码互转 bitmap2Bytes, bytes2Bitmap : bitmap 与 byteArr 互...
byte[] data = byte_Out.toByteArray(); response.setContentType("application/octet-stream" ); response.setContentLength( data.length ); response.setStatus( response.SC_OK ); OutputStream out_...
依靠InputStream和OutputStream两个类及其子类实现。lnputStream 类及其子类主要负责输入数据, 如果需要通过键盘输入数据. InputStream类巾的read方法是最常用的输入方法。许多学生学习过 程中产生迷惑, 以及出现...
Java Io Extras 这是一个库,用于在Scala和java.io之间进行额外的集成,这应该使在Scala中使用java....val iterator : Iterator [ Byte ] = InputStreamIterator (inputStream) // convert an Iterator[Byte] to an I