开发者

How to make java.io.Console display a default for the user to confirm or modify?

the new http://download.oracle.com/javase/6/docs/api/java/io/Console.html class seems ok for user input from the console, however, it seems to provide no way to read a line but with the default already filed in (so the user only has to press enter to confirm or delete to modify).

How can i do this with the clas开发者_StackOverflows?


If the line is empty, use the default. Using commons-lang's StringUtils (or your favorite way of testing for empty lines)

if (StringUtils.isBlank(lineRead)) lineRead = "whatever default";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜