Question: Where do you put in the file name Crime.csv in the following code? Also where do you put the csv file in netbeans? public static

Where do you put in the file name Crime.csv in the following code? Also where do you put the csv file in netbeans?

public static String[][] getArray (String filename){

//fields

BufferedReader br = null;

final int COLUMN = 20;

final int ROW = 21;

String array[][] = new String[ROW][COLUMN];

//Read the CSV file

//Setup try/catch/finally blocks for exception handling

try {

//setup input reader

String currentLine;

br = new BufferedReader(new FileReader(filename));

//while loop to read input, provide output and count

int count = 0;

while ((currentLine = br.readLine()) != null) {

for (int i = count; i < ROW; i++) {

array[i] = currentLine.split(",");

}

count++;

}

} catch (IOException e) {

//output exception stack

System.out.println(" There was an issue. Please make sure you have the correct file.");

System.exit(1);

} finally {

try {

if (br != null) {

br.close();

}

} catch (IOException ex) {

System.out.println(" There was an issue.");

System.exit(1);

}

}

return array;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!