Skip to content

Commit 34dede5

Browse files
committed
添加代码
1 parent 7044135 commit 34dede5

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package cn.byhieg.iotutorial.bytestreamio;
2+
3+
import java.io.BufferedInputStream;
4+
import java.io.File;
5+
import java.io.FileInputStream;
6+
7+
/**
8+
* Created by shiqifeng on 2017/2/23.
9+
* Mail byhieg@gmail.com
10+
*/
11+
public class BufferdInputStreamExample {
12+
13+
public void readFromFile() throws Exception{
14+
String s = File.separator;
15+
try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream("D:" + s + "read_file.txt"))) {
16+
byte[] bytes = new byte[1024];
17+
while (bis.read(bytes) != -1) {
18+
String str = new String(bytes);
19+
System.out.println(str);
20+
}
21+
}
22+
}
23+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package cn.byhieg.iotutorialtest;
2+
3+
import cn.byhieg.iotutorial.bytestreamio.BufferdInputStreamExample;
4+
import junit.framework.TestCase;
5+
6+
/**
7+
* Created by shiqifeng on 2017/2/23.
8+
* Mail byhieg@gmail.com
9+
*/
10+
public class BufferdInputStreamExampleTest extends TestCase {
11+
public void testReadFromFile() throws Exception {
12+
new BufferdInputStreamExample().readFromFile();
13+
}
14+
15+
}

0 commit comments

Comments
 (0)