Skip to content

Commit 0b869a4

Browse files
author
crazy
committed
IO操作复习
1 parent 03077dc commit 0b869a4

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

JavaBase/IOTest.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
IOTestDemo
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.xinan.io;
2+
3+
import java.io.File;
4+
import java.io.FileInputStream;
5+
import java.io.FileNotFoundException;
6+
import java.io.InputStream;
7+
8+
public class FileInputStreamDemo {
9+
10+
public static void main(String[] args) throws Exception {
11+
// TODO Auto-generated method stub
12+
//创建源
13+
File f=new File("D:/GitHub/Java4_JavaBase/JavaBase/IOTest.txt");
14+
//创建输入流对象
15+
InputStream in=new FileInputStream(f);
16+
17+
byte[] buffer=new byte[5];
18+
int len=-1;
19+
while((len=in.read(buffer))!=-1){
20+
String str=new String(buffer,0,len);
21+
System.out.println(str);
22+
}
23+
in.close();
24+
}
25+
26+
}

JavaBase/乘法口诀表.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)