PasswordAuthentication GetUserName() Example
Returns the user name.
PasswordAuthenticationclass GetUserName() method example. This example shows you how to use GetUserName() method.This method Returns the user name.
Here is the code:-
/*
* @Program that Returns the user name.
* GetUserName.java
* Author:-RoseIndia Team
* Date:-28-Jun-2008
*/
import java.net.*;
public class GetUserName {
public static void main(String[] args) throws Exception {
String userName = "Girish";
char[] password = {'R', 'o', 's', 'e', 'i', 'n', 'd', 'i', 'a'};
PasswordAuthentication authentication =
new PasswordAuthentication(userName, password);
System.out.print("The user name is: ");
//Returns the user name.
System.out.println(authentication.getUserName());
}
} |
|