File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
main/java/cn/byhieg/iotutorial/bytestreamio
test/java/cn/byhieg/iotutorialtest Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments