I'm reading from a csv file which has this layout:
CS4092,B CS2013,A CS8291,C CS0927,D CS0281,A
When I do print it out, I get this output:
CS4092 BMA4042 CCS4023 ACS4075 BCS4010 A
The output I'm trying to achieve is:
CS4092 - B CS2013 - A CS8291 - C CS0927 - D CS0281 - A
Can someone please tell me what way I can get the desired output. Thanks.
public class Student
{
private String studentID;
public Student()
{
}
public void setID(String studentID)
{
this.studentID = studentID;
}
public void checkResults() throws IOException
{
String lines = "", unparsedFile = "", myArray[];
String path = System.getProperty("user.home") +
"/NetBeansProjects/CS4013Project/src/" +
this.studentID + "Results.csv";
FileReader fr = new FileReader(path);
try (BufferedReader br = new BufferedReader(fr))
{
while((lines = br.readLine()) != null)
{
unparsedFile += lines;
}
}
myArray = unparsedFile.split(",");
for(String item : myArray)
{
System.out.println(item);
}
}
}