Last active
June 24, 2019 07:27
-
-
Save team172011/656ade57a741a24ab5fd8cabf6db4166 to your computer and use it in GitHub Desktop.
Write the content of a file (InputStream) to an String variable
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
public static String getFileContent(FileInputStream fis, String encoding ) throws IOException{ | |
try(BufferedReader br =new BufferedReader(new InputStreamReader(fis, encoding))){ | |
StringBuilder sb = new StringBuilder(); | |
String line; | |
while(( line = br.readLine()) != null ) { | |
sb.append( line ); | |
sb.append( '\n' ); | |
} | |
return sb.toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment