62,615
社区成员
发帖
与我相关
我的任务
分享
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class BytesStreamTest
{
private static int BUFFER_SIZE = 1024;
public static void main(String[] args) throws Exception
{
readTest();
}
public static void readTest() throws Exception
{
FileInputStream fis = new FileInputStream("output.txt");
byte[] buf = new byte[BUFFER_SIZE];
int ch = 0;
while((ch = fis.read(buf)) != -1)
{
System.out.println(new String(buf,0,ch));
}
fis.close();
}
}
public static void readTest() throws Exception {
FileInputStream fis = new FileInputStream("output.txt");
byte[] buf = new byte[1024];
int ch = 0;
if( 0 != (ch = fis.read(buf))){
System.out.println(new String(buf, 0, ch));
}
fis.close();
}