For some reason my java program can't find my textfile if i use file.next to display contents of the file but if use file.readLine it finds and shows the contencts of the filebut not the way i want for example:
I want actual output like this:
1: Humps Black Eyed Peas 3.3 Hip-Hop 4.2
But if i use next readline it displays like this:
1,Humps,Black Eyed Peas,3.3,Hip-Hop,4.2
Here is my code:
`try
{
BufferedReader data = new BufferedReader(new FileReader(new File("songCollection.txt")));
Scanner inFile = new Scanner(data);
line = data.readLine();
System.out.printf("SongID\t " + "\tSongName\t " + "\tArtist\t " + "Duration\t " + "\tGenre\t " + "\tRating\t " );
while(line != null)
{
while(inFile.hasNext())
{
//SongClass songs = new SongClass(line);
//songlists.add(songs);
//songs.setSongID(inFile.nextInt());
System.out.println(line);
line = data.readLine();
}
System.out.println(line);
line = data.readLine();
}
}catch(Exception eo)
{
System.out.println("File Not be Found ");
}
`