Advertisement
Guest User

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

a guest
Apr 18th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. private static int readFileToInt(String filename) {
  2. String fileContent = "1";
  3.  
  4. BufferedReader br = null;
  5. try {
  6.  
  7. try {
  8. br = new BufferedReader(new FileReader(filename));
  9.  
  10. String line;
  11.  
  12. while ((line = br.readLine()) != null) {
  13. fileContent = fileContent + line;
  14. }
  15. } catch (FileNotFoundException e) {
  16. System.out.println("File not found at " + filename);
  17.  
  18. }
  19.  
  20. } catch (IOException e) {
  21.  
  22. e.printStackTrace();
  23.  
  24. }
  25. return Integer.parseInt(fileContent.replaceAll("[^0-9.]", ""));
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement