<code>InputStream fileSource = req.getInputStream();
String tempFile =
"/home/joy/桌面/tempFile"
;
FileOutputStream tempFileOutputStream =
new
FileOutputStream(tempFile);
byte[] bytes =
new
byte[10 * 1024];
int i = 0;
while
((i = fileSource.read(bytes, 0, bytes.length)) != -1) {
System.out.println(
"已读字节:"
+ i +
", 剩余字节: "
+ fileSource.available());
System.out.println(
new
String(bytes));
tempFileOutputStream.write(bytes);
tempFileOutputStream.
flush
();
if
(fileSource.available() < bytes.length) {
bytes =
new
byte[fileSource.available()];
}
}
tempFileOutputStream.close();
fileSource.close();
</code>