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的更多相关文章

  1. Java IO 之 FileInputStream & FileOutputStream源码分析

    Writer      :BYSocket(泥沙砖瓦浆木匠) 微         博:BYSocket 豆         瓣:BYSocket FaceBook:BYSocket Twitter   ...

  2. Java基础知识强化之IO流笔记22:FileInputStream / FileOutputStream 复制文本文件案例1

    1. 使用字节流FileInputStream / FileOutputStream 复制文本文件案例: 分析: (1)数据源:从哪里来 a.txt   --   读取数据  --  FileInpu ...

  3. Java基础 FileInputStream/ FileOutputStream / 字节输入流 字节输出流实现文件的复制

    FileInputStream/FileOutputStream的笔记: /**(FileInputStream/FileOutputStream四个步骤: ①声明②加载地址③read/write④c ...

  4. Java字节流:FileInputStream FileOutputStream

    ----------------------------------------------------------------------------------- FileInputStream ...

  5. java io读书笔记(8)FileInputStream/FileOutputStream的应用

    转自:http://www.cnblogs.com/jjtech/archive/2011/04/17/2019210.html 这是一对继承于InputStream和OutputStream的类,用 ...

  6. Java API —— IO流( FileInputStream & FileOutputStream & BufferedInputStream & BufferedOutputStream )

    1.IO流概述 · IO流用来处理设备之间的数据传输        · 上传文件和下载文件        · Java对数据的操作是通过流的方式 · Java用于操作流的对象都在IO包中   2.IO ...

  7. Java基础知识强化之IO流笔记26:FileInputStream / FileOutputStream 复制mp4视频的案例

    1.  需求:把D:\\English.mp4 复制到当前项目目录下copy.mp4 代码示例: package com.himi.filecopy; import java.io.FileInput ...

  8. Java基础知识强化之IO流笔记25:FileInputStream / FileOutputStream 复制图片案例

    1.  需求:把D:\\美女.jpg 复制到当前项目目录下mn.jpg 代码示例: package com.himi.filecopy; import java.io.FileInputStream; ...

  9. Java基础知识强化之IO流笔记24:FileInputStream / FileOutputStream 复制文本文件案例2

    1. 需求:把d盘下的a.txt的内容复制到f盘下的b.txt中: 代码示例: package com.himi.filecopy; import java.io.FileInputStream; i ...

随机推荐

  1. pyqt5-对文本样式进行操作

    self.label_2 = QtWidgets.QLabel(self.centralWidget) self.label_2.setGeometry(QtCore.QRect(330, 220, ...

  2. 浅谈KMP算法

    一.介绍 烤馍片KMP算法是用来处理字符串匹配问题的.比如说给你两个字符串A,B,问B是不是A的子串? 比如,eg就是aeggx的子串 一般讲字符串A称为主串,用来匹配的B串称为模式串 定义n为字符串 ...

  3. Activiti(生成25张表)

    有两种方式,第一种是使用默认的配置文件,第二种是指定配置文件: package com.ouyan.activiti.table; import org.activiti.engine.Process ...

  4. ios多播委托

    在现实中回调的需求也分两种 一对一的回调. 一对多的回调. 对于一对一的回调,在IOS中使用delegate.block都能实现.而一对多的回调基本就是通知中心了. 假如现在有一个需求,我们以图片下载 ...

  5. larabbs安装教程

    LaraBBS 是一个简洁的论坛应用,使用 Laravel5.5 编写而成.https://github.com/summerblue/larabbs 1. 克隆源代码克隆 larabbs 源代码到本 ...

  6. wordpress如何去掉generator

    用wordpress建站经常会出现一些显而易见的标签,比如说作者<meta name="generator" content="WordPress 4.9" ...

  7. OC常用控件封装

    #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @interface CreateUI : NSObject ...

  8. shell字符串数组

    数组 声明数组 declare -a ARRAY_NAME declare -A ARRAY_NAME: 关联数组 注意:两者不可相互转换 数组名和下标(索引) 索引:编号从0开始,属于数值索引 注意 ...

  9. 003-RFC关于媒体类型说明

    一.概述 RFC-822   Standard for ARPA Internet text messages [ARPA互连网文本信息标准]RFC-2045 MIME Part 1: Format ...

  10. SQLite数据库管理工具(SQLiteStudio)v3.1.1

    http://www.pc6.com/softview/SoftView_86552.html