当前位置:网站首页>FileInputStream and fileoutputstream
FileInputStream and fileoutputstream
2022-07-03 07:21:00 【four thousand three hundred and forty-three】
FileReader And FileWriter Can only be used for text files , Such as .txt,.java,.c,.c++ etc.
For the picture , Byte stream files such as video need byte stream, i.e :FileInputStream And FileOutputStream
package IOStream;
import org.junit.Test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class InputOutputStream {
@Test
public void test() throws IOException {
FileInputStream fis = null;
FileOutputStream fos = null;
try {
File srcFile = new File("hanyang.png");
File destFile = new File("hanyang1.png");
fis = new FileInputStream(srcFile);
fos = new FileOutputStream("hanyang1.png");
byte[] buffer = new byte[5];
int len ;
while((len = fis.read(buffer))!= -1){
fos.write(buffer,0,len);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
边栏推荐
- C code production YUV420 planar format file
- TCP cumulative acknowledgement and window value update
- SecureCRT取消Session记录的密码
- Recursion, Fibonacci sequence
- Jeecg data button permission settings
- Summary of Arduino serial functions related to print read
- Distributed ID
- 树莓派更新工具链
- Arduino 软串口通信 的几点体会
- Operation and maintenance technical support personnel have hardware maintenance experience in Hong Kong
猜你喜欢
Wireshark software usage
Docker builds MySQL: the specified path of version 5.7 cannot be mounted.
Jmeter+influxdb+grafana of performance tools to create visual real-time monitoring of pressure measurement -- problem record
IPv4 address
【已解决】SQLException: Invalid value for getInt() - ‘田鹏‘
Deep learning parameter initialization (I) Xavier initialization with code
Specified interval inversion in the linked list
高并发内存池
PdfWriter. GetInstance throws system Nullreferenceexception [en] pdfwriter GetInstance throws System. NullRef
SecureCRT取消Session记录的密码
随机推荐
Win 2008 R2 crashed at the final installation stage
【最详细】最新最全Redis面试大全(50道)
【CMake】CMake链接SQLite库
[cmake] cmake link SQLite Library
Use of framework
Upgrade CentOS php7.2.24 to php7.3
3311. 最长算术
Advanced API (multithreading 02)
Summary of Arduino serial functions related to print read
The difference between typescript let and VaR
The underlying mechanism of advertising on websites
Le Seigneur des anneaux: l'anneau du pouvoir
Pits encountered in the use of El checkbox group
php安装composer
VMware virtual machine installation
docker建立mysql:5.7版本指定路径挂载不上。
Advanced API (multithreading)
IP home online query platform
GStreamer ffmpeg avdec decoded data flow analysis
Common analysis with criteria method