InputStream 一个字节一个字节的读取
来源:互联网 发布:python图像识别汉字 编辑:程序博客网 时间:2024/05/10 00:20
package chap10.sec03;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
public class Demo4 {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
File file =new File("D:/测试文件.txt");
InputStream in=new FileInputStream(file);//实例化FileInputStream
int fileLength=(int)file.length();
byte b[]=new byte[fileLength];
int temp=0;
int len=0;
while((temp=in.read())!=-1){
b[len++]=(byte) temp;
}
in.close();
System.out.println("读取到的内容是:"+new String(b));
}
}
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
public class Demo4 {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
File file =new File("D:/测试文件.txt");
InputStream in=new FileInputStream(file);//实例化FileInputStream
int fileLength=(int)file.length();
byte b[]=new byte[fileLength];
int temp=0;
int len=0;
while((temp=in.read())!=-1){
b[len++]=(byte) temp;
}
in.close();
System.out.println("读取到的内容是:"+new String(b));
}
}
1 0
- InputStream 一个字节一个字节的读取
- 将读取的图片的InputStream流转为字节流
- 将读取的图片的InputStream流转为字节流
- InputStream的read方法读取字节不完全的问题
- InputStream的read方法读取字节不完全的解决方案
- socket输入流中读取一个固定长度的字节
- 反转一个字节的算法
- 一个十六进制字节的困惑
- 一个字节的表示范围
- 编写一个程序,它读取一个文件以判断其中的字节数,然后使用0覆盖所有的字节
- 反转一个字节
- 把一个字节倒过来
- 为什么空类占一个字节?
- 一个字节处理类
- 为什么空类占一个字节?
- IO流_FileInputStream读取数据一次一个字节数组
- 读取字节的方式
- Android -- 小问题 InputStream的read方法读取字节不完全的问题
- C++作业7-函数复习
- C语言逻辑流程
- android4.4的短信发送流程
- 域名与DNS(域名解析服务器)
- TCP,UDP,三次握手
- InputStream 一个字节一个字节的读取
- 刷刷笔试题~~(6)[C++]
- 对java值传递和引用传递的理解
- Main函数的参数
- 工厂模式
- [jvm解析系列][四]Java的垃圾回收(二)垃圾收集算法,内存分配和回收策略
- Course学习之旅--UW的Machine Learning Foundations: A Case Study Approach--Lession 1
- java的面试题:缓冲池(-128~127)
- 1097. Deduplication on a Linked List (25)