如何在Java中输入控制台时隐藏密码
我正在Java中开发一个在线订单管理系统,该系统连接MySQL以在控制台中运行,我需要使用用户ID和密码登录。因此,在这里,我需要在输入控制台时掩盖密码。有人可以帮我吗?
I am developing a online order management system in java connecting MySql to run in console where I need to login using userid and password. so, here I need to mask the password while typing in console. can anyone pls, help me with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
班级 console 有一个方法
ReadPassword()
可能对您的情况有所帮助。The class Console has a method
readPassword()
that might be helpful in your case.char [] password = system.console()。readPassword(“密码:”);
注意:您不能在IDE中运行此代码,必须在终端执行。
char[] password = System.console().readPassword("password:");
notice: you can't run this code in IDE, you have to execute on terminal.