This article is a mirror article of machine translation, please click here to jump to the original article.

View: 5690|Reply: 0

[Source] Java InputStream replicate clones, solving the problem of multiple reads

[Copy link]
Posted on 12/3/2021 10:10:22 AM | | |
When developing web interfaces, we may need to read the values of InputStream multiple times, such as interceptor verification signatures, packet format verification, etc.

Review:

Java byte[] and InputStream are converted to each other
https://www.itsvse.com/thread-10033-1-1.html

Method 1:

Introduce "hutool-all" first, the code is as follows:


Method 2 (not tested):

The general contract for mark is that if the method markSupported returns true, then the input stream always logs all the bytes read after the mark is called, and is always ready to serve those same bytes again when the method reset is called, whenever it is called. However, if more bytes than readlimit can be read from the stream before reset is called, the stream does not need to log any data. Parameter: readlimit - The maximum limit on the number of bytes that can be read before the tag position is invalidated.





Previous:Deploy SQL Server 2019 database on Docker
Next:Win10 Home Chinese Edition Enables Remote Desktop (Solves the Problem of Castration)
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com