Results 1 to 2 of 2
- 10-18-2010, 12:47 AM #1
Member
- Join Date
- Oct 2010
- Posts
- 12
- Rep Power
- 0
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
and here is my codeXML Code:http://www.nfl.com/gamecenter/2010101004/2010/REG5/rams@lions/recap http://www.nfl.com/gamecenter/2010101008/2010/REG5/giants@texans/recap
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 delimetersJava 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)); } } } }
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
-
Please don't post the same question in more than one forum. I'm locking this thread as your question is a basic one and belongs in the new to java forum. A couple of suggestions:
1) Please be patient. We are volunteers not paid, and most will try to answer your question when they have the time.
2) Your indentation is terrible making it very difficult to read and understand your code, and you'll be likely to have more folks willing to read your code if you format it properly. Frankly this is the reason I personally didn't attempt to answer your question -- I couldn't read your code.
Luck.
Similar Threads
-
How to use delimiter in java
By adityasirohi in forum New To JavaReplies: 1Last Post: 02-12-2010, 10:01 PM -
How do you Use Backslash as a Delimiter?
By Mobius-1 in forum New To JavaReplies: 3Last Post: 12-14-2009, 12:39 AM -
Delimiter question
By Kangaroo128 in forum New To JavaReplies: 10Last Post: 09-09-2009, 09:28 AM -
using Delimiter with metacharacters
By wntdaliv in forum New To JavaReplies: 10Last Post: 12-02-2008, 06:42 AM -
delimiter
By satin in forum New To JavaReplies: 2Last Post: 11-17-2008, 10:50 PM


LinkBack URL
About LinkBacks

Bookmarks