File tree Expand file tree Collapse file tree
collectiontutorial/listtutorial
test/java/cn/byhieg/iotutorialtest Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package cn .byhieg .annotationstutorial ;
22
3- import sun .jvm .hotspot .runtime .amd64 .AMD64CurrentFrameGuess ;
43
54import java .lang .reflect .InvocationTargetException ;
65import java .lang .reflect .Method ;
Original file line number Diff line number Diff line change 11package cn .byhieg .collectiontutorial .listtutorial ;
22
3- import apple .laf .JRSUIFocus ;
4-
53/**
64 * Created by byhieg on 17/2/15.
75 * Mail to byhieg@gmail.com
Original file line number Diff line number Diff line change 1+ package cn .byhieg .iotutorial .bytestreamio ;
2+
3+ import java .io .ByteArrayOutputStream ;
4+ import java .io .FileInputStream ;
5+ import java .io .FileNotFoundException ;
6+ import java .io .InputStream ;
7+
8+ /**
9+ * Created by shiqifeng on 2017/2/23.
10+ * Mail byhieg@gmail.com
11+ */
12+ public class ByteArrayOutPutStreamExample {
13+
14+ public void writeFromFile () throws Exception {
15+ try (InputStream is = new FileInputStream ("D://read_file.txt" )) {
16+ ByteArrayOutputStream output = new ByteArrayOutputStream ();
17+ byte [] bytes = new byte [1024 ];
18+ while (is .read (bytes ) != -1 ) {
19+ output .write (bytes );
20+ }
21+
22+ String data = output .toString ("UTF-8" );
23+ System .out .println (data );
24+
25+ }
26+ }
27+ }
Original file line number Diff line number Diff line change 1+ package cn .byhieg .iotutorialtest ;
2+
3+ import cn .byhieg .iotutorial .bytestreamio .ByteArrayOutPutStreamExample ;
4+ import junit .framework .TestCase ;
5+
6+ /**
7+ * Created by shiqifeng on 2017/2/23.
8+ * Mail byhieg@gmail.com
9+ */
10+ public class ByteArrayOutPutStreamExampleTest extends TestCase {
11+ public void testWriteFromFile () throws Exception {
12+ new ByteArrayOutPutStreamExample ().writeFromFile ();
13+ }
14+
15+ }
You can’t perform that action at this time.
0 commit comments