Username Domain StringTokenizer coderinme

Username Domain StringTokenizer coderinme

Print Username and Domain of an Email in separate lines using StringTokenizer
Let us now Write a program that prompts for and read e-mail address of a user. The program then prints the user name and the domain name on different lines using StringTokenizer class. That is, this program shall will read an text of an email id from keyboard entered by the user and then using StringTokenizer class, it will print the username and the domain of email id in separate lines.
Hint: break the line from the “@” symbol when encountered in the email address
Program:

import java.util.*;
public class Q28 
{
public static void main(String[] args) 
{
String mail="coderinme@gmail.com";
StringTokenizer st=new StringTokenizer(mail,"@",false);
while(st.hasMoreTokens()) {
String token=st.nextToken();
System.out.println(token);
}
}
}

For more programs on Java, visit our Java Archives

Username Domain StringTokenizer coderinme

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme

Leave a reply:

Your email address will not be published.