当前位置:网站首页>Introduction of buffer flow
Introduction of buffer flow
2022-07-03 07:21:00 【four thousand three hundred and forty-three】
package BufferStream;
/*
The use of buffer streams
*/
import org.junit.Test;
import java.io.*;
public class BufferTest {
/*
Realize the copy of non text file
*/
@Test
public void BufferedStreamTest() throws IOException {
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
// 1. Document making object
File srcFile = new File("hanyang.png");
File destFile = new File("hangyang2.png");
// 2. Create byte stream
FileInputStream fis = new FileInputStream(srcFile);
FileOutputStream fos = new FileOutputStream(destFile);
// 2.2 Create a buffer stream
bis = new BufferedInputStream(fis);
bos = new BufferedOutputStream(fos);
// 3. Data manipulation
byte[] buffer = new byte[5];
int len ;
while ((len = bis.read(buffer))!=-1){
bos.write(buffer,0,len);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (bos!=null) {
bos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
if (bis!=null) {
bis.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
// 4. Resources to shut down : Close the outer layer first , Then close the inner layer . notes : While closing the outer layer , The inner flow will also be automatically closed
// fos.close();
// fis.close();
}
}
边栏推荐
- Warehouse database fields_ Summary of SQL problems in kingbase8 migration of Jincang database
- The education of a value investor
- Chrome 98 Private Network Access problem w/ disabled web security: Request had no target IP address
- sharepoint 2007 versions
- How to specify the execution order for multiple global exception handling classes
- Advanced API (serialization & deserialization)
- Dora (discover offer request recognition) process of obtaining IP address
- 【最詳細】最新最全Redis面試大全(50道)
- 7.2刷题两个
- IPv4 address
猜你喜欢
TCP cumulative acknowledgement and window value update
Hash table, generic
Interfaces and related concepts
Pits encountered in the use of El checkbox group
Spa single page application
PdfWriter. GetInstance throws system Nullreferenceexception [en] pdfwriter GetInstance throws System. NullRef
[Fiddler actual operation] how to use Fiddler to capture packets on Apple Mobile Phones
Setting up the development environment of dataworks custom function
Recursion, Fibonacci sequence
JUC forkjoinpool branch merge framework - work theft
随机推荐
Jmeter+influxdb+grafana of performance tools to create visual real-time monitoring of pressure measurement -- problem record
Deep learning parameter initialization (I) Xavier initialization with code
"Moss ma not found" solution
Operation and maintenance technical support personnel have hardware maintenance experience in Hong Kong
Use of framework
7.2 brush two questions
File operation serialization recursive copy
1. E-commerce tool cefsharp autojs MySQL Alibaba cloud react C RPA automated script, open source log
Homology policy / cross domain and cross domain solutions /web security attacks CSRF and XSS
sharepoint 2007 versions
【最详细】最新最全Redis面试大全(50道)
Advanced APL (realize group chat room)
Interview questions about producers and consumers (important)
SharePoint modification usage analysis report is more than 30 days
Recursion, Fibonacci sequence
Discussion on some problems of array
Margin left: -100% understanding in the Grail layout
Jeecg data button permission settings
Raspberry pie update tool chain
Arduino Serial系列函数 有关print read 的总结