I/O from the Command Line

Java控制台交互方式
[url]http://java.sun.com/docs/books/tutorial/essential/io/cl.html[/url]

The Java platform supports this kind of interaction in two ways: through the Standard Streams and through the Console.

java平台支持2种控制台交互方式。1是通过标准的stream 另外一种就是 console

[b]Standard Streams[/b]

InputStreamReader cin = new InputStreamReader(System.in);



[b]The Console[/b]
[url]http://java.sun.com/javase/6/docs/api/java/io/Console.html[/url]
Console流相对标准流来说是一个更高级的选项。Console类有大部分标准流提供的功能。另外它特别适合用户名密码这样的情况

why?

This method helps secure password entry in two ways. First, it suppresses echoing, so the password is [b]not visible[/b] on the user's screen. Second, readPassword returns a[b] character array[/b], not a String, so the password can be overwritten, removing it from memory as soon as it is no longer needed.


char [] oldPassword = c.readPassword("Enter your old password: ");


System.console()

这个对象有可能返回一个null。原因是 not permitted / OS doesn't support them / or because the program was launched in a noninteractive environment.
你确定?linuxHCI 到底是什么 通俗易懂的讲 我给你看一下linuxHCI 文件夹下面的东西 #include <stdio.h> #include <string.h> #include <stdlib.h> #include "LinuxSPPLE.h" /* Main Application Prototypes and Constants. */ #include "SS1BTPS.h" /* Includes for the SS1 Bluetooth Protocol Stack. */ #include "SS1BTDBG.h" /* Includes/Constants for Bluetooth Debugging. */ #include "SS1BTGAT.h" /* Includes for the SS1 GATT Profile. */ #include "SS1BTGAP.h" /* Includes for the SS1 GAP Service. */ #include "SS1BTDIS.h" /* Inlcudes for Device Information Service. */ #define printErr(fmt, args...) printf("\033[1m[ %s ] %03d: "fmt"\033[0m", __FUNCTION__, __LINE__, ##args) #define printWar(fmt, args...) printf("\033[4m[ %s ] %03d: "fmt"\033[0m", __FUNCTION__, __LINE__, ##args) #define NUM_EXPECTED_PARAMETERS_USB (2) /* Denotes the number*/ /* of command line */ /* parameters */ /* accepted at Run */ /* Time when running */ /* in USB Mode. */ #define NUM_EXPECTED_PARAMETERS_UART (4) /* Denotes the */ /* number of command */ /* line parameters */ /* accepted at Run */ /* Time when running */ /* in UART Mode. */ #define USB_PARAMETER_VALUE (0) /* Denotes the value */ /* passed in on the */ /* command line for */ /* running with the */ /* transport set to */ /* USB. */ #define UART_PARAMETER_VALUE (1) /* Denotes the value */ /* passed in on the */ /* command line for */ /* running with the */ /* transport set to */ /* UART. */ #define BCSP_PARAMETER_VALUE (2) /* Denotes the value */ /* passed in on the */ /* command line for */ /* running with the */ /* transport set to */ /* BCSP. */ #define MAX_SUPPORTED_COMMANDS (36) /* Denotes the */ /* maximum number of */ /* User Commands that*/ /* are supported by */ /* this application. */ #define MAX_COMMAND_LENGTH (64) /* Denotes the max */ /* buffer size used */ /* for user commands */ /* input via the */ /* User Interface. */ #define MAX_NUM_OF_PARAMETERS (5) /* Denotes the max */ /* number of */ /* parameters a */ /* command can have. */ #define DEFAULT_IO_CAPABILITY (licNoInputNoOutput) /* Denotes the */ /* default I/O */ /* Capability that is*/ /* used with Pairing.*/ #define DEFAULT_MITM_PROTECTION (TRUE) /* Denotes the */ /* default value used*/ /* for Man in the */ /* Middle (MITM) */ /* protection used */ /* with Secure Simple*/ /* Pairing. */ #define DEFAULT_SECURE_CONNECTIONS (TRUE) /* Denotes the */ /* default value used*/ /* for Secure */ /* Connections. */ #define SPPLE_DATA_BUFFER_LENGTH (BTPS_CONFIGURATION_GATT_DEFAULT_MAXIMUM_SUPPORTED_MTU_SIZE) /* Defines the length*/ /* of a SPPLE Data */ /* Buffer. */ #define SPPLE_DATA_CREDITS (SPPLE_DATA_BUFFER_LENGTH*3) /* Defines the */ /* number of credits */ /* in an SPPLE Buffer*/ #define LED_TOGGLE_RATE_SUCCESS (500) /* The LED Toggle */ /* rate when the demo*/ /* successfully */ /* starts up. */ #define CONSOLE_MONITOR_RATE (10) /* The rate at which */ /* the console will */ /* be tested for */ /* input. */ #define NO_COMMAND_ERROR (-1) /* Denotes that no */ /* command was */ /* specified to the */ /* parser. */ #define INVALID_COMMAND_ERROR (-2) /* Denotes that the */ /* Command does not */ /* exist for */ /* processing. */ #define EXIT_CODE (-3) /* Denotes that the */ /* Command specified */ /* was the Exit */ /* Command. */ #define FUNCTION_ERROR (-4) /* Denotes that an */ /* error occurred in */ /* execution of the */ /* Command Function. */ #define TO_MANY_PARAMS (-5) /* Denotes that there*/ /* are more */ /* parameters then */ /* will fit in the */ /* UserCommand. */ #define INVALID_PARAMETERS_ERROR (-6) /* Denotes that an */ /* error occurred due*/ /* to the fact that */ /* one or more of the*/ /* required */ /* parameters were */ /* invalid. */ #define UNABLE_TO_INITIALIZE_STACK (-7) /* Denotes that an */ /* error occurred */ /* while Initializing*/ /* the Bluetooth */ /* Protocol Stack. */ #define INVALID_STACK_ID_ERROR (-8) /* Denotes that an */ /* occurred due to */ /* attempted */ /* execution of a */ /* Command when a */ /* Bluetooth Protocol*/ /* Stack has not been*/ /* opened. */ #define UNABLE_TO_REGISTER_SERVER (-9) /* Denotes that an */ /* error occurred */ /* when trying to */ /* create a Serial */ /* Port Server. */ #define EXIT_MODE (-10) /* Flags exit from */ /* any Mode. */
最新发布
11-27
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值