I'm getting an error using the method readFile
which I used in the class RunProgram
.
The error I'm getting is:
RunProgram.java uses unchecked or unsafe operations.
The code of my RunProgram
class is:
import java.util.ArrayList;
public class RunProgram{
public static void main(String [] args){
String [] namen = Input.geefInputNamen();
ArrayList<Spelers> spelerDatabase = new ArrayList<Spelers>();
spelerDatabase = FileReader.readFile("Player Database");
}
}
The method readFile
is defined in the code below:
import java.io.*;
import java.util.ArrayList;
public class FileReader {
public static ArrayList readFile(String naamvdfile) {
ArrayList<Spelers> spelerDatabase = new ArrayList<Spelers>();
try {
int LineNr = 4;
File aFile = new File (naamvdfile+ ".xlsx");
BufferedReader aBr = new BufferedReader(new java.io.FileReader(aFile));
String aLine ="";
while (aLine !=> null) {
aLine = aBr.readLine();
if (aLine != null) {
String [] lineParts = aLine.split(";", -1);
if (lineParts.length == 10) {
int overall = Integer.parseInt(lineParts[1]);
int shootMid = Integer.parseInt(lineParts[4]);
int shootDis = Integer.parseInt(lineParts[5]);
int defence = Integer.parseInt(lineParts[6]);
int rebounden = Integer.parseInt(lineParts[7]);
int playmaker = Integer.parseInt(lineParts[8]);
int atletisch = Integer.parseInt(lineParts[9]);
Spelers speler = new Spelers(lineParts[0], overall,
lineParts[2], lineParts[3], shootMid, shootDis,
defence, rebounden, playmaker, atletisch);
spelerDatabase.add(speler);
}
else System.out.println("Lijn " + LineNr +" is niet volledig
ingevuld!");
LineNr++;
}
}
System.out.println("Aantal spelers dat we inlazen: " + LineNr);
}
catch (Exception e) { }
return spelerDatabase;
}
}
This last code doesn't give an error while compiling.