Created
July 23, 2016 08:11
-
-
Save carlosdlf/192356b01654430b2e4b4fcd01ba838c 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
public static StringBuilder readFile(File $f) throws IOException { | |
StringBuilder sb = new StringBuilder(); | |
BufferedReader br = null; | |
try { | |
String sCurrentLine; | |
br = new BufferedReader(new FileReader($f)); | |
while ((sCurrentLine = br.readLine()) != null) { | |
sb.append(sCurrentLine).append("\n"); | |
} | |
} catch (IOException e) { | |
throw new IOException("Error leyendo archivo"); | |
} finally { | |
try { | |
if (br != null)br.close(); | |
} catch (IOException ex) { | |
throw new IOException("Error cerrando archivo"); | |
} | |
} | |
return sb; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment