如何将InputStreamReader
转换为InputStream
?我有一个InputStream
其中包含一些字符串和字节数据,我想解析它。所以我把我的InputStream
换成BufferedReader
。然后我读了3行。之后,我想按原样获取其余数据(字节)。但是如果我试图得到它没有任何反应。 代码片段:将InputStreamReader转换为InputStream
BufferedReader br = new BufferedReader(new InputStreamReader(is,"UTF-8"));
String endOfData = br.readLine();
String contentDisposition = br.readLine();
String contentType = br.readLine();
file = new File(filename);
if(file.exists()) file.delete();
file.createNewFile();
FileOutputStream fos = new FileOutputStream(file);
byte[] data = new byte[8192];
int len = 0;
while (-1 != (len = is.read(data)))
{
fos.write(data, 0, len);
Log.e("len", len+"");
}
fos.flush();
fos.close();
is.close();
该文件是空的。如果我不包装InputStream
它工作正常,但我需要读取3行并将其删除。 谢谢。