Why would I want to use java.io.Console over standard streams? -
i realize may duplicate question, such as, why use java.io.console?. however, wanted more detailed answer (pros/cons, applications, more).
forgive me if misunderstanding this. ran program using eclipse , received error message "no console", let go , ran via terminal instead. however, little unclear why console object doing (i think it's because returns null, wanted more detailed answer). various reads, seems various ides such netbeans , eclipse haven't "implemented" properly. leads me question, , since first time seeing java.io.console
, why want use on standard streams? examples applications using console appreciated , preferred!
programs written interactive shells in mind provide lot of conveniences command line users
- tab completion
- history tracking
- password input secure against shoulder surfers
- colored , formatted output
- using preferred pager paging text
console
allows java programs invoked via command line present user-experience users invoke in interactive shell.
for example, console.readline
might sound similar bufferedreader.readline
, when program run interactive bash
shell, behaves unix readline
description
readline read line terminal , return it, using prompt prompt. if prompt null or empty string, no prompt issued. line returned allocated malloc(3); caller must free when finished. line returned has final newline removed, text of line remains.
readline offers editing capabilities while user entering line. default, line editing commands similar of emacs. vi-style line editing interface available.
...
searching
readline provides commands searching through command history lines containing specified string. there 2 search modes: incremental , non-incremental.
why want use on standard streams?
if program produces textual output , users include sysadmins invoke inside interactive shell, might benefit console
.
Comments
Post a Comment