Results 1 to 5 of 5
Thread: hasNext call
- 06-20-2010, 12:41 PM #1
Member
- Join Date
- Jun 2010
- Posts
- 6
- Rep Power
- 0
hasNext call
Hi,
trying to create a program that reads off usernames from the email add..
this is the code:
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
class TestinOne
{
public static void main(String args[])
throws FileNotFoundException
{
Scanner diskScanner = new Scanner(new File("email1.txt"));
PrintStream diskWriter = new PrintStream ("usernamesright.txt");
char symbol;
while(diskScanner.hasNext())
{
symbol = diskScanner.findInLine(".").charAt(0);
while ( symbol != '@')
{
diskWriter.print(symbol);
symbol = diskScanner.findInLine(".").charAt(0);
}
}
diskScanner.nextLine();
diskWriter.println();
}
}
but its not working..
any solutions?
thkx
- 06-20-2010, 12:51 PM #2
Can you show what it does do, why that is wrong and what you want changed?but its not working
Does "diskScanner.findInLine(".")" always return a String? Read the doc.
Maybe you should test what is returned first.Last edited by Norm; 06-20-2010 at 12:53 PM.
- 06-20-2010, 01:58 PM #3
Senior Member
- Join Date
- May 2010
- Posts
- 436
- Rep Power
- 4
And also "it's not working" doesn't help us help you. Please see: It Doesnt Work Is Useless
- 06-20-2010, 03:47 PM #4
Member
- Join Date
- Jun 2010
- Posts
- 6
- Rep Power
- 0
Hi,
sry abt the lack of details..
instead of getting the usernames only, whatever comes before and after the @ is printed in the usernamesright.txt file. ie instead of printing joho from the email address joho@hotmail.com, it prints johohotmail.com..
plus it does not go till the end of the file..ie the second email add username is not being printed..
any solutions..
thks
- 06-20-2010, 03:58 PM #5
Similar Threads
-
call a JSP method
By sauravsinha in forum JavaServer Pages (JSP) and JSTLReplies: 4Last Post: 09-26-2011, 04:19 PM -
gwt rpc asynchronous call
By trust in forum Web FrameworksReplies: 1Last Post: 08-11-2009, 10:42 AM -
not able to call the ejb
By deepak9976 in forum Enterprise JavaBeans (EJB)Replies: 0Last Post: 08-07-2009, 10:12 AM -
how to call method?
By leapinlizard in forum New To JavaReplies: 9Last Post: 04-29-2009, 11:55 PM -
Using scanner.hasNext() but recognize return
By ScKaSx in forum New To JavaReplies: 5Last Post: 01-27-2009, 10:11 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks