How To Accept Password From Console in Java كيف لقبول كلمة السر من console في يافا
Finally you can easily accept password from console in Java, without echoing them. واخيرا هل يمكن ان يقبل بسهولة من console كلمة السر في يافا ، دون ان يردد لها.
This long unmet need has been addressed in هذه المده الطويلة من الاحتياجات غير الملباه تم تناولها في JDK 1.6 1،6 وهم ج. codeline.
A new class - طبقة جديدة -- java.io.Console java.io.console has been defined to handle console I/O. وقد عرفت لمعالجة console الاول / سين
To accept password from console in من لقبول كلمة السر في console JDK 6.0 (aka JDK 1.6) وهم ج 6.0 (1.6 اكا وهم ج.) use either: اما استخدام :
public char[] readPassword() شار العامة [] readpassword ()
or او
public char[] readPassword(String fmt, Object… args) شار العامة [] readpassword (سلسلة الاداه ، وجوه 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, ‘ ‘); } نموذج رمز : console الدستوري ؛ شار [] passwd ؛ اذا كانت الاجابه ب ((الدستوري system.console = ())! = اغيه & & (passwd = cons.readpassword ( "[٪]" ، و "كلمة السر :"))! = باطل) (/ / استخدام passwd لتوثيق… الخ. ؛ / / الكود / / بعد انتهائك الصفر طابع المصفوفه في الذاكرة للحد من المخاطر الامنية java.util.arrays.fill (passwd ، '') ؛) So could I entice you yet to بذلك يمكن أن تغري لكم انني بعد download JDK 1.6 تحميل وهم ج 1،6 ? ؟
Filed under المقدم بمقتضى Headline News أهم الانباء , ، How To كيف , ، Java Software برنامج جافا , ، Tech Note ملاحظه تقنيه | |
| |
RSS 2.0 ار اس اس 2،0 | |
Email this Article ارسل هذه المادة
You may also like to read ويمكنك ايضا ان تقرأ |




January 12th, 2006 at 10:45 am كانون الثاني / يناير 12th ، 2006 في الساعة 10:45
[...] India Fourth Largest Internet User How To Accept Password From Console in Java » JDK1.6 / JDK 6.0 Downloaded? [...]الهند رابع اكبر مستخدم الانترنت كيف لقبول كلمة السر من console في جاوه »jdk1.6 اريد جدك 1.6 / وهم ج 6،0 تنزيلها؟ January 12th, 2006 by AngsumanChakraborty [...] كانون الثاني / يناير 12th ، 2006 angsumanchakraborty [...]
June 8th, 2006 at 6:21 am في الثامن من يونيو 2006 فى الساعة 6:21
thanks for the service you provided to me. شكرا لأنك قدمت خدمة لي.
November 19th, 2007 at 7:46 pm تشرين الثاني / نوفمبر 19th ، 2007 في الساعة 7:46
Console c = System.console(); ج console = system.console () ؛
if(c != null){ اذا كان (ج! = لاغيه) (
String user = new String(c.readLine(”Enter user:”)); الخيط المستخدم = سلسلة جديدة (c.readline ( "دخول المستخدم :"))؛
String pwd = new String(c.readPassword(”Enter pwd:”)); سلسلة جديدة pwd = الخيط (c.readpassword ( "ادخل pwd :"))؛
c.printf(”%20s”,user); c.printf ( "٪ العشرينات من العمر" ، المستخدم) ؛
c.printf(”\n%20s\n”,pwd); c.printf ( "\ n ٪ العشرينات من العمر \ n" ، pwd) ؛
}else ) والا
System.out.println(”Console is unavailable”); System.out.println ( "console غير متوفره") ؛
注意運行環境為:jdk1.6+jcreator3.5.注意运行环境为: jdk1.6 اريد جدك 1.6 + jcreator3.5.
如果jcreator4.0的話,得到的c總是null.如果jcreator4.0的话،得到的ج总是لاغيه.
March 28th, 2008 at 6:46 am مارس 28th ، 2008 في الساعة 6:46
it,s very nice ، ق لطيف جدا