bufferedinputStream操作
- import java.io.BufferedInputStream;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- public class BufferedInputStreamTest {
- public static void main(String[] args) throws IOException {
- File file = new File("c:\\mm.txt");
- FileInputStream fis = new FileInputStream(file);
- BufferedInputStream bis = new BufferedInputStream(fis);
- byte[] contents = new byte[1024];
- int byteRead = 0;
- String strFileContents;
- try {
- while((byteRead = bis.read(contents)) != -1){
- strFileContents = new String(contents,0,byteRead);
- System.out.println(strFileContents);
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- bis.close();
- }
- }
- import java.io.BufferedInputStream;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- public class ReadFileTest {
- public static void main(String[] args) throws IOException {
- File file = new File("c:\\mm.txt");
- FileInputStream fis = new FileInputStream(file);
- BufferedInputStream bis = new BufferedInputStream(fis);
- while(bis.available() > 0){
- System.out.print((char)bis.read());
- }
- bis.close();
- }
- }
- import java.io.BufferedInputStream;
- import java.io.BufferedOutputStream;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.InputStream;
- public class BufferedInputStreamCopyFile {
- public static void main(String[] args) throws IOException {
- BufferedInputStream bis = new BufferedInputStream(new FileInputStream("d:\\电影\\sn.ts"));
- BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("d:\\电影sn1.ts"));
- int i;
- do{
- i = bis.read();
- if(i != -1){
- bos.write(i);
- }
- }while(i != -1);
- bis.close();
- bos.close();
- }
- }
bufferedinputStream操作的更多相关文章
- Java基础17:Java IO流总结
更多内容请关注微信公众号[Java技术江湖] 这是一位阿里 Java 工程师的技术小站,作者黄小斜,专注 Java 相关技术:SSM.SpringBoot.MySQL.分布式.中间件.集群.Linux ...
- Java IO: 字符流的Buffered和Filter
作者: Jakob Jenkov 译者: 李璟(jlee381344197@gmail.com) 本章节将简要介绍缓冲与过滤相关的reader和writer,主要涉及BufferedReader.B ...
- [转]Android - 文件读写操作 总结
转自:http://blog.csdn.net/ztp800201/article/details/7322110 Android - 文件读写操作 总结 分类: Android2012-03-05 ...
- JAVASE02-Unit07: 基本IO操作 、 文本数据IO操作
基本IO操作 . 文本数据IO操作 java标准IO(input/output)操作 package day07; import java.io.FileOutputStream; import ja ...
- Java的文件读写操作
file(内存)----输入流---->[程序]----输出流---->file(内存) 当我们读写文本文件的时候,采用Reader是非常方便的,比如FileReader,InputStr ...
- Java使用poi操作cexel
Java操作excel比较简单,但是时间长了就会忘记,因此基本的简单操作做个记录. 依赖poi的jar包,pom.xml配置如下: <project xmlns="http://mav ...
- Java基础复习笔记系列 七 IO操作
Java基础复习笔记系列之 IO操作 我们说的出入,都是站在程序的角度来说的.FileInputStream是读入数据.?????? 1.流是什么东西? 这章的理解的关键是:形象思维.一个管道插入了一 ...
- Java字节流:BufferedInputStream BufferedOutputStream
-----------------------------------------------------------------------------------BufferedInputStre ...
- java中的IO操作总结
一.InputStream重用技巧(利用ByteArrayOutputStream) 对同一个InputStream对象进行使用多次. 比如,客户端从服务器获取数据 ,利用HttpURLConnect ...
随机推荐
- Makefile的常用技术总结
一.MAKE中的自动变量: $@: 表示target的名字 $%: 仅当目标是函数库文件中,表示规则中的目标成员名.例如,如果一个目标是"foo.a(bar.o)",那 ...
- 4.js屏蔽浏览器鼠标右键菜单
document.oncontextmenu = function(){return false;} 参考链接:js 屏蔽浏览器事件汇总
- mfc为对话框添加启动画面
新建CwzdSplash类 CwzdSplash.h #pragma once class CWzdSplash : public CWnd { DECLARE_DYNAMIC(CWzdSplash) ...
- c/c++面试39-44之内存动态分配
39 指针的初始化(二叉树排序),其中引入了双向链表 #include <stdio.h> #include <stdlib.h> struct Tag_Node { stru ...
- Flutter实战视频-移动电商-19.首页_火爆专区界面布局编写
19.首页_火爆专区界面布局编写 看一下图片的效果 一个标题栏,下面是多行两列.里面可以用column布局,外面用Warp流式布局 有得小伙伴说这里可以用网格布局,网格布局的话还是有一定的效率问题.这 ...
- SmartSql使用教程(3)——SmartSql中的事务,及AOP的使用
一.引言 经过两章的铺垫,我们现在对SmartSql已经有了一定的了解,那么今天我们的主题是事务处理.事务处理是常用的一种特性,而SmartSql至少提供了两种使用事务的方法.一种是通过Reposit ...
- 进击python第一篇:相遇
1.第一句Python代码 在 当前目录下创建 hello.py 文件,内容如下: print "hello,world!" 执行 hello.py 文件,即: python he ...
- 单片机的C语言中位操作用法
在对单处机进行编程的过程中,对位的操作是经常遇到的.C51对位的操控能力是非常强大的.从这一点上,就可以看出C不光具有高级语言的灵活性,又有低级语言贴近硬件的特点.这也是在各个领域中都可以看到C的重要 ...
- 最长上升序列(Lis)
Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence ...
- SpringBoot | 启动异常 | 显示bulid success 无 error信息
可能原因是没有添加 web 依赖,检查pom里面是否有web <dependency> <groupId>org.springframework.boot</groupI ...