How To Accept Password From Console in Java 비밀 번호를 수락하는 방법 자바 콘솔에서
Finally you can easily accept password from console in Java, without echoing them. 마지막으로 비밀 번호를 수락하실 수있습니다 콘솔에 쉽게 자바, 그들이 울리지 않고있습니다.
This long unmet need has been addressed in 이 긴 미해결 필요가에서 해결되었습니다 JDK 1.6 1.6 jdk codeline. codeline합니다.
A new class - 새 클래스 - java.io.Console java.io.console has been defined to handle console I/O. 이 정의되지 콘솔을 처리할 / 오
To accept password from console in 콘솔에 비밀 번호를 수락 JDK 6.0 (aka JDK 1.6) jdk 6.0 (일명 jdk 1.6) use either: 사용 :
public char[] readPassword() 공용 문자 [] readpassword ()
or 또는
public char[] readPassword(String fmt, Object… args) 공용 문자 [] readpassword (문자열 fmt, 개체… args)
Sample code: Console cons; char[] passwd; if ((cons = System.console()) != null && (passwd = cons.readPassword(”[%s]“, “Password:”)) != null) { // Use the passwd for authentication etc. ….; // Your code // After you are done zero the character array in memory for reducing security risk java.util.Arrays.fill(passwd, ‘ ‘); } 샘플 코드 : 콘솔 단점; 문자 [] 비밀 번호; 경우 ((단점 = system.console ())! = 널 & & (비밀 번호 = cons.readpassword ( "[%의]", "비밀 번호 :"))! = 널) (/ / 인증을위한 비밀 번호를 사용하여 등등….; / / 당신의 코드 / / 제로의 문자 배열이 완료 후에는 메모리에서 보안 위험을 줄이기위한 java.util.arrays.fill (비밀 번호, '');) So could I entice you yet to 그래서 유도를 아직 수 있을까요 download JDK 1.6 jdk 1.6을 다운로드 ?
Filed under 밑에 Headline News 헤드 라인 뉴스 , How To 하는 방법을 , Java Software 자바 소프트웨어 , Tech Note 기술 참고 사항 | |
| |
RSS 2.0 rss 2.0 | |
Email this Article 전자 우편이 문서
You may also like to read 같은를 읽을 수있습니다 |




January 12th, 2006 at 10:45 am 2006년 1월 12일에서 오전 10시 45분
[...] India Fourth Largest Internet User How To Accept Password From Console in Java » JDK1.6 / JDK 6.0 Downloaded? [...] 인도에서 4 번째로 큰 인터넷 사용자 비밀 번호를 수용하는 방법을 콘솔에 자바»jdk1.6를 원한다 / jdk 6.0을 다운로드? January 12th, 2006 by AngsumanChakraborty [...] 2006년 1월 12일 의해 [...] angsumanchakraborty
June 8th, 2006 at 6:21 am 2006년 6월 8일에서 오전 6시 21분
thanks for the service you provided to me. 제공되는 서비스를 내 주셔서 감사합니다.
November 19th, 2007 at 7:46 pm 2007년 11월 19일에서 오후 7시 46분
Console c = System.console(); 콘솔 c = system.console ();
if(c != null){ 만약 (c! = 널) (
String user = new String(c.readLine(”Enter user:”)); 문자열을 사용자 = 새 문자열 (c.readline ( "을 입력 사용자 :"));
String pwd = new String(c.readPassword(”Enter pwd:”)); 문자열을 장애인 = 새 문자열 (c.readpassword ( "을 입력 장애인 :"));
c.printf(”%20s”,user); c.printf ( "% 20", 사용자);
c.printf(”\n%20s\n”,pwd); c.printf ( "\ n % 20 대 \ n", 장애인);
}else ) 다른 사람
System.out.println(”Console is unavailable”); system.out.println ( "콘솔을 사용할 수없습니다");
注意運行環境為:jdk1.6+jcreator3.5.注意运行环境为: jdk1.6를 원한다 + jcreator3.5합니다.
如果jcreator4.0的話,得到的c總是null.如果jcreator4.0的话,得到的c总是널합니다.
March 28th, 2008 at 6:46 am 2008년 3월 28일에서 오전 6시 46분
it,s very nice ,의 아주 좋은