|
||
|
|||
|
Hi,
First of all, this is my first proper post for help on this forum, so hello to everyone! It's good to be here! ![]() Now, down the business... I have a problem with a command-line application which emulates an SQL DBMS environment. (not really that important to the problem per se, but it might give you some scope and perspective...) The problem I have concerns the ability to intercept the user's action of pasting several commands (composed of several lines) from their clipboard into the Java's input. I'll use the following example: If I have the following string in the clipboard: "select * from example;\r select * from example;\r select * from example;\r" ...where '\r' is the return character to execute the command... ...and i paste it into the console at the prompt, then we get the following in each scenario: ========================== THIS IS HOW ANY SQL DBMS DISPLAYS IT: ========================== Java Code
prompt> select * from example;
col1 | col2
------+--------
1 | Value1
2 | Value2
3 | Value3
(3 rows)
prompt> select * from example;
col1 | col2
------+--------
1 | Value1
2 | Value2
3 | Value3
(3 rows)
prompt> select * from example;
col1 | col2
------+--------
1 | Value1
2 | Value2
3 | Value3
(3 rows)
...this is the normal output that I wish to achieve... but... ========================== THIS IS HOW JAVA DISPLAYS IT: ========================== Java Code
prompt> select * from example;
select * from example;
select * from example;
col1 | col2
------+--------
1 | Value1
2 | Value2
3 | Value3
(3 rows)
col1 | col2
------+--------
1 | Value1
2 | Value2
3 | Value3
(3 rows)
col1 | col2
------+--------
1 | Value1
2 | Value2
3 | Value3
(3 rows)
...so the difference being that Java simply allows all 3 commands to be "visible" (printed) on the terminal screen before executing each command, which doesn't look good! I'm currently using a BufferedReader which wraps an InputStreamReader to do the job. Here's the code I use to read... Java Code
...
BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in));
while (running == true) {
try {
System.out.print("prompt> ");
command = inputReader.readLine();
...
// Some SQL-related parsing
...
executeCommand(command);
} catch (IOException e) {
System.out.println("ERROR Reading Input. Please try again!");
}
}
...
Any thoughts on this matter would be greatly appreciated. Thanks in advance!
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Changing output from console to .html | RSYR | File I/O & Other I/O Streams | 6 | 10-12-2009 11:55 PM |
| printing output to console & to a text file at the same time... | prasanna | File I/O & Other I/O Streams | 3 | 26-08-2009 08:43 AM |
| [SOLVED] help with console input strnig.... | mdstrauss | File I/O & Other I/O Streams | 5 | 17-08-2009 08:59 AM |
| How to Read user input from the console with the Scanner class | JavaPF | Java Code Snippets and Tutorials | 0 | 11-11-2008 06:47 PM |
| How to Read user input from the console with InputStreamReader | JavaPF | Java Code Snippets and Tutorials | 0 | 19-05-2008 11:48 AM |