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 ...
随机推荐
- 使用github的srs代码,搭建 RTMP_Server
1. 搭建RTMP服务器 1> 获取开源代码SRS. git clone https://github.com/ossrs/srs 下载源码后,按照如下文档安装https://github.co ...
- es组合多个条件进行查询
GET /test_index/_search{ "query": { "bool": { "must": { "match&qu ...
- JavaScript学习(七)
- Http服务基础原理
http服务相关解释 http : Hyper Text Transfer Protocol, 80/tcp 超文本传输协议,基于tcp传输协议的80端口传输 html: Hyper Text M ...
- PowerTCP FTP for .NET 在线e文文档
http://www.dart.com/help/ptftpnet/webframe.html
- Scala的apply unapply unapplySeq 语法糖
apply 可以理解为注入 unapply unapplySeq 可以理解为提取 apply 与 unapply 虽然名字相近,但是使用起来区别挺大.apply有点像构造函数unapply主要是结合模 ...
- [js]arguments属性
类数组 具有length属性的对象称为类数组 观察他的顺序 为什么能转换 for(let i=0;i<arr.length;i++){ console.log(arr[i]); } https: ...
- Android 7.0下,拍摄照片报错
对于面向 Android 7.0 的应用,Android 框架执行的 StrictMode API 政策禁止在您的应用外部公开 file:// URI.如果一项包含文件 URI 的 intent 离开 ...
- Java知识点-判断null、空字符串和空格
Java知识点-判断null.空字符串和空格 // 判断headerKey是否为null,空字符串或者空格 if (headerKey != null && headerKey.len ...
- 算法bug修复
问题一: 160length:4length:4length:4length:4290length:2length:2160length:5length:5length:5length:5length ...