forked from hmkcode/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.java
More file actions
31 lines (22 loc) · 1.18 KB
/
App.java
File metadata and controls
31 lines (22 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.hmkcode;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
public class App
{
public static void main( String[] args ) throws IOException
{
// 1. By java.util.Scanner
InputStream inputStream = new ByteArrayInputStream("hmkcode..inputStream to String".getBytes());
System.out.println("getStringByScanner: "+InputStreamToString.getStringByScanner(inputStream));
// 2. By BufferedReader
inputStream = new ByteArrayInputStream("hmkcode..inputStream to String".getBytes());
System.out.println("getStringByBufferedReader: " +InputStreamToString.getStringByBufferedReader(inputStream));
// 3. By Apache IO
inputStream = new ByteArrayInputStream("hmkcode..inputStream to String".getBytes());
System.out.println("getStringByApacheIO IOUtils.toString: "+InputStreamToString.getStringByApacheIO_toString(inputStream));
// 4. By Apache IO
inputStream = new ByteArrayInputStream("hmkcode..inputStream to String".getBytes());
System.out.println("getStringByApacheIO IOUtils.copy: "+InputStreamToString.getStringByApacheIO_copy(inputStream));
}
}