OutputStream只能以byte或byte数组写文件,为了写字符串,我们调用String的get-Bytes方法得到它的UTF-8编码...
public static void main(String[] args) throws Exception{ //1.创建FileInputStream,并指定文件路径 FileInputStream fis=new FileInputStream("d:\\aaa.txt"); //2.1读取文件(单个字节读取) // fis.read() // int data=0; // while ((data= fis.read())!=-1){ // System.out.print((char)da...
int length = 0;while(-1 != (length = is.read(buffer, 0, buffer.length))){ String str = new String(buffer,0,length);System.out.println(str);}
BoundedRangeFileInputStream.read() @Overridepublicintread()throwsIOException{intret=read(oneByte);if(ret==1)returnoneByte[0]&0xff;return-1;} 代码来源:org.apache.hadoop/hadoop-common BoundedRangeFileInputStream.read(...) @Overridepublicintread(byte[]b)throwsIOException{returnread(b,0,b.length)...
学习IO框架中的FileInputStream的read方法过程中出现了问题,下面把代码先放出来: 1. package com.IOclass.demo01; import com.sun.org.apache.xpath.internal.operations.String; import java.io.FileInputStream; /** * 演示FileInputStream的使用 * 文件字节输入流 ...