Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Andrew Cz
Added: Nov 29, 2018 3:01 PM
Modified: Nov 29, 2018 3:27 PM
Views: 0
Tags: no tags
checks the path and read in the file, if available. Path to be changed
  1. public static List<String> readFile() {
  2.         List<String> lines = new ArrayList<>();
  3.         try {
  4.             lines = Files.readAllLines(Paths.get("src/crash-incidents.csv"));
  5.         } catch (IOException e) {
  6.             System.err.println("the file is not found or readable");
  7.         }
  8.         return lines;
  9.     }
  10.  
  11.     OR TRY THIS
  12.  
  13.     try {
  14.                 Path filePath = Paths.get("src/mostproductiveyear/" + studioName + ".csv");
  15.                 lines = Files.readAllLines(filePath);
  16.             } catch (Exception e) {
  17.                 System.out.println("sorry, the file is not found or not readable");
  18.             }