Here is my code so far, apparently I've created an infinite loop as the program never stops spitting out numbers even though the .txt file has run out of items. Below is only what I threw together to see if I could count each individual item, before I try to code it to do individual lines.
import java.util.Scanner;
import java.io.*;
public class Tester
{
public static void main(String[] args) throws IOException
{
Scanner fileScan = new Scanner (new File("playlist.txt"));
fileScan.useDelimiter(",");
int linecount = 0;
while (fileScan.hasNext())
{
linecount++;
System.out.print(linecount);
}
}
}
The text file I am using is as follows:
Kashmir,508,Led Zeppelin,Mothership,Rock,5,25,null,null
Viva la Vida,244,Coldplay,Viva la Vida,Alternative,5,30,null,null
Bad Data Example,65,Not,Enough,Fields
Bittersweet Symphony,358,The Verve,Urban Hymns,Rock,4,19,null,null
Hush,265,Deep Purple,Shades of Deep Purple,Rock,4,15,null,null
Yahweh,262,U2,How to Dismantle an Atomic Bomb,Rock,5,31,null,null
Any and all help is appreciated. If I haven't been clear about what I'm trying to do let me know
This post has been edited by RayneShock: 26 August 2009 - 05:59 PM

New Topic/Question
Reply



MultiQuote





|