parent
c4248e604d
commit
e443d30c2b
@ -0,0 +1,29 @@
|
||||
package ${domain}.base.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public class StreamUtil {
|
||||
|
||||
public static InputStream string2Stream(String str) {
|
||||
return new ByteArrayInputStream(str.getBytes());
|
||||
}
|
||||
|
||||
public static String stream2String(InputStream is) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(is));
|
||||
String line;
|
||||
try {
|
||||
while ((line = br.readLine()) != null) {
|
||||
sb.append(line);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String str = sb.toString();
|
||||
return str;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue