help plz with delimiter and while loop
Hello im new to java and i have a hw where i have to use delimeter and separate each word from url....and i cant use arrays so im kinda trapped
i searched everywhere but i couldnt find any good solution
well my url.txt file contents 2 lines
i posted on new to java but many views no reply so thought this is lil advance
Code:
http://www.nfl.com/gamecenter/2010101004/2010/REG5/rams@lions/recap
http://www.nfl.com/gamecenter/2010101008/2010/REG5/giants@texans/recap
and here is my code
Code:
import java.util.Scanner;
import java.io.*;
public class scanfile
{
public static void main(String[] args) throws IOException
{
int k=0;
int z =0;
Scanner s,s2;
String l,p;
s= new Scanner(new File("url.txt"));
s.hasNext();
while (s.hasNext() == true)
{
l= s.nextLine();
s2=new Scanner(l);
s2.useDelimiter("/");
while (s2.hasNext())
{
p=s2.next();
k=p.length();
// System.out.println(k+" "+p);
while (p.charAt(z) == '@')
{
z++;
}
System.out.println(p.substring(0,z));
}
}
}
}
the whole point of the program is to print the home team and after i compile it i get completly blank output....and i made sure the delimeter works by printing the words and length of the words between the delimeters
so plzzzz help
i kept working on it with the same code and i keep getting string index out of bound error...not the blank screen