Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Design With Microcomputer Applications

Authors: Glenn A. Jackson

1st Edition

0137718411, 978-0137718412

More Books

Students also viewed these Databases questions