当前位置:网站首页>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();
}
}
}
}
边栏推荐
- VMware virtual machine installation
- Le Seigneur des anneaux: l'anneau du pouvoir
- New stills of Lord of the rings: the ring of strength: the caster of the ring of strength appears
- 《指環王:力量之戒》新劇照 力量之戒鑄造者亮相
- [set theory] partition (partition | partition example | partition and equivalence relationship)
- php artisan
- SecureCRT password to cancel session recording
- php安装swoole扩展
- Common APIs
- 萬卷書 - 價值投資者指南 [The Education of a Value Investor]
猜你喜欢

高并发内存池

691. Cube IV

JS monitors empty objects and empty references

IP home online query platform

JUC forkjoinpool branch merge framework - work theft
![[Fiddler actual operation] how to use Fiddler to capture packets on Apple Mobile Phones](/img/d0/850e095a43610366d6144b2471f3f7.jpg)
[Fiddler actual operation] how to use Fiddler to capture packets on Apple Mobile Phones

Summary of Arduino serial functions related to print read
![[set theory] equivalence classes (concept of equivalence classes | examples of equivalence classes | properties of equivalence classes | quotient sets | examples of quotient sets)*](/img/1f/f579110a408c5b5a094733be57ed90.jpg)
[set theory] equivalence classes (concept of equivalence classes | examples of equivalence classes | properties of equivalence classes | quotient sets | examples of quotient sets)*
![[set theory] partition (partition | partition example | partition and equivalence relationship)](/img/f0/c3c82de52d563f3b81d731ba74e3a2.jpg)
[set theory] partition (partition | partition example | partition and equivalence relationship)

Store WordPress media content on 4everland to complete decentralized storage
随机推荐
Interfaces and related concepts
Operation and maintenance technical support personnel have hardware maintenance experience in Hong Kong
[day15] introduce the features, advantages and disadvantages of promise, and how to implement it internally. Implement promise by hand
691. Cube IV
When MySQL inserts Chinese into the database, there is a diamond question mark garbled code
Crontab scheduled task
4279. 笛卡尔树
Inno setup production and installation package
树莓派更新工具链
Jeecg data button permission settings
[set theory] partition (partition | partition example | partition and equivalence relationship)
Docker builds MySQL: the specified path of version 5.7 cannot be mounted.
How can I split a string at the first occurrence of “-” (minus sign) into two $vars with PHP?
JS date comparison
Le Seigneur des anneaux: l'anneau du pouvoir
Win 10 find the port and close the port
3311. 最长算术
Advanced API (use of file class)
Basic components and intermediate components
II. D3.js draw a simple figure -- circle