Last active
April 15, 2016 21:22
-
-
Save skyfishjy/9bb7ed533d85b88dc9ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
/** | |
* Created by skyfishjy on 5/5/15. | |
*/ | |
public class IOUtils { | |
/** | |
* Reads an input stream line by line and converts it into String. | |
* @param inputStream the inputStream need to convert | |
*/ | |
public static String convertStreamToString(InputStream inputStream) { | |
BufferedReader bufferedReader; | |
StringBuilder stringBuilder = new StringBuilder(); | |
try { | |
String line; | |
bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF8")); | |
while ((line = bufferedReader.readLine()) != null) { | |
stringBuilder.append(line); | |
} | |
bufferedReader.close(); | |
} catch (IOException ignored) { | |
} | |
return stringBuilder.toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment