在我做文件上传是,可以取到java.io.InputStream.现在要取到单个byte.不知道如何写,希望各位大侠,多多指点
------解决方案--------------------
"int InputStream.read() " 读取的数据实际上就是一个byte,而不是一个int
------解决方案--------------------
FormFile file = form.getFacefile();
InputStream inputStream = file.getInputStream();
OutputStream outputStream = new FileOutputStream( "test.txt ");
int bytesRead = 0;
byte[] buffer = new byte[8192];
while ((bytesRead = inputStream.read(buffer, 0, 8192)) != -1)
{
outputStream.write(buffer, 0, bytesRead);
}
outputStream.close();
inputStream.close();
file.destroy();