FileInputStream FileOutputStream
FileInputStream is a stream to grab the information from files.Combined with FileOutputStream, we can achieve the function of copying.
Examples:
public class Demo4 {
public static void main(String[] args) {
String content = null;
byte[] buffer = new byte[1024];
int size = 0;
File file = new File("C:/Users/caich5/Desktop/aaaa.txt");
InputStream input = null;
try {
input = new FileInputStream(file);
OutputStream output = new FileOutputStream("C:/Users/caich5/Desktop/tttd.txt");
while((size = input.read(buffer))!= -1){
//show in console
content = new String(buffer,0,size);
System.out.println(content);
//copy to another file
output.write(buffer, 0, size);
}
input.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Tips: FileInputStream,FileOutputStream,both of them are low lever stream.
FileInputStream FileOutputStream的更多相关文章
- Java IO 之 FileInputStream & FileOutputStream源码分析
Writer :BYSocket(泥沙砖瓦浆木匠) 微 博:BYSocket 豆 瓣:BYSocket FaceBook:BYSocket Twitter ...
- Java基础知识强化之IO流笔记22:FileInputStream / FileOutputStream 复制文本文件案例1
1. 使用字节流FileInputStream / FileOutputStream 复制文本文件案例: 分析: (1)数据源:从哪里来 a.txt -- 读取数据 -- FileInpu ...
- Java基础 FileInputStream/ FileOutputStream / 字节输入流 字节输出流实现文件的复制
FileInputStream/FileOutputStream的笔记: /**(FileInputStream/FileOutputStream四个步骤: ①声明②加载地址③read/write④c ...
- Java字节流:FileInputStream FileOutputStream
----------------------------------------------------------------------------------- FileInputStream ...
- java io读书笔记(8)FileInputStream/FileOutputStream的应用
转自:http://www.cnblogs.com/jjtech/archive/2011/04/17/2019210.html 这是一对继承于InputStream和OutputStream的类,用 ...
- Java API —— IO流( FileInputStream & FileOutputStream & BufferedInputStream & BufferedOutputStream )
1.IO流概述 · IO流用来处理设备之间的数据传输 · 上传文件和下载文件 · Java对数据的操作是通过流的方式 · Java用于操作流的对象都在IO包中 2.IO ...
- Java基础知识强化之IO流笔记26:FileInputStream / FileOutputStream 复制mp4视频的案例
1. 需求:把D:\\English.mp4 复制到当前项目目录下copy.mp4 代码示例: package com.himi.filecopy; import java.io.FileInput ...
- Java基础知识强化之IO流笔记25:FileInputStream / FileOutputStream 复制图片案例
1. 需求:把D:\\美女.jpg 复制到当前项目目录下mn.jpg 代码示例: package com.himi.filecopy; import java.io.FileInputStream; ...
- Java基础知识强化之IO流笔记24:FileInputStream / FileOutputStream 复制文本文件案例2
1. 需求:把d盘下的a.txt的内容复制到f盘下的b.txt中: 代码示例: package com.himi.filecopy; import java.io.FileInputStream; i ...
随机推荐
- sharepoint webapp 部署注意点
只有在配置文件或 Page 指令中将 enableSessionState 设置为 true 时,才能使用会话状态.还请确保在应用程序配置的 // 节中包括 System.Web.SessionSta ...
- C#生成exe、dll版本号自动增加
修改AssemblyInfo.cs 1.注释[assembly: AssemblyFileVersion("1.0.0.0")] 2.[assembly: AssemblyVers ...
- InnoDB Lock
众所周知innodb的锁是行级锁,这样说也没有问题,只是还可以细分而已.推荐阅读何登成大牛的博客http://hedengcheng.com/?p=771 innodb的锁有三种算法,分别如下: Re ...
- Navigator is deprecated and has been removed from this package
报错:'Navigator is deprecated and has been removed from this package. It can now be installed ' + ...
- TADOConnection组件
该组件用于建立数据库的连接.ADO的数据源组件和命令组件可以通过该组件运行命令及数据库中提取数据等. 该组件用于建立数据库的连接,该连接可被多个数据集所共享,但是并不是应用程序中必须的,因为ADO数据 ...
- MySQL语法和用户授权
管理数据库 create database 等同于 create schema #导入数据库脚本 MariaDB [db1]> source /root/mysql/hellodb_in ...
- 前端框架之Vue(6)-列表渲染
用v-for把一个数组对应为一组元素 我们用 v-for 指令根据一组数组的选项列表进行渲染. v-for 指令需要使用 item in items 形式的特殊语法, items 是源数据数组并且 i ...
- 微信小程序中this使用
微信小程序中,在wx.request({});方法调用成功或者失败之后,有时候会需要获取页面初始化数据data的情况,这个时候,如果使用,this.data来获取,会出现获取不到的情况,调试页面也会报 ...
- 2018-2019-1 20189221《Linux内核原理与分析》第五周作业
2018-2019-1 20189221<Linux内核原理与分析>第五周作业 实验四 实验过程 当用户态进程调用一个系统调用时,cpu切换到内核态并开始执行一个内核函数. 在Linux中 ...
- [LeetCode] 566. Reshape the Matrix_Easy
In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new o ...