java.io.IOException markreset not supported exception

java.io.IOException: mark/reset not supported 异常

Problem statement:

​ The given stream does not support markand resetoperation

problem analysis:

mark​The resetsum operation requires the input stream to be able to move the read/write head back and forth. Generally, the input stream is read and written in the buffer, but the InpurStreaminput stream has no buffer, so the sum mechanism is InputStreamnot allowedmarkreset

problem solved:

​ Since markthe AND resetoperation requires the input stream to have a buffer, and because BufferedInputStreamit inherits from FilterInputStream, it provides the function of buffering the input stream, so it can InpurStreambe packaged BufferedInputStream.

code:

// 定义一个输入流
InputStream is = null;

// 将 InputStream 输入流打包成 BufferedInputStream
BufferedInputStream bfi = new BufferedInputStream(is);

Guess you like

Origin blog.csdn.net/xiri_/article/details/124016810