Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
String, text, numbers, I/O I part<br />
}<br />
}<br />
System.out.println("Invalid parameters!!!");<br />
System.exit(0);<br />
}<br />
File fl = new File(args[0]);<br />
FileReader fileReader = new FileReader(fl);<br />
BufferedReader bufferedReader = new BufferedReader(fileReader);<br />
String currentLine;<br />
while( (currentLine = bufferedReader.readLine()) != null ){<br />
System.out.println(currentLine);<br />
}<br />
Q: Does anybody know a convenient way to pause the dos program execution<br />
until user hits enter? In C I used getc. Does <strong>Java</strong> have an equivalent of "cin>>"?<br />
Answer:<br />
try {<br />
System.in.read()<br />
} catch (Exception e) {<br />
}<br />
Have fun!<br />
--<br />
Bary<br />
I've got a (simple) menu on a new application and am trying to put in the works<br />
behind the cut, copy & paste menu options - does anyone know how I can do this -<br />
what's the code or can you point me in the right direction?<br />
Answer: Look at java.awt.datatransfer package. It contains much of the tools<br />
necessary to implement cut. copy, paste.<br />
Can anyone please explain clearly how BufferedReader works and how to use it to<br />
get input from a keyboard?<br />
Q: Can anyone please explain clearly how BufferedReader works and how to<br />
use it to get input from a keyboard?<br />
Answer: BufferedReader is a filter reader class.<br />
That is, it wraps another reader and reading from it is like reading from the reader it<br />
wraps, except that it changes something. In the case of BufferedReader, it reads in<br />
large chunks and then you can retrieve its data in smaller bits. To use it to read from<br />
System.in, you first need a reader to wrap. You can bridge from an input stream<br />
(which System.in is) to a reader by using an InputStreamReader.<br />
Then wrap that in a BufferedReader as follows:<br />
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));<br />
Now you can call methods of BufferedReader to read from standard input. Generally,<br />
you create a BufferedReader to be able to call the readLine() method. That isn't<br />
BufferedReader's main intended use -- the main intended use is performance -- but<br />
you don't generally care too awfully much about performance of reads from the<br />
console. So call readLine to get a line of input, which will be null on end of stream<br />
(user presses Ctrl-D on UNIX or a file was redirected in and is done).<br />
answered by Chris Smith<br />
file:///F|/350_t/350_tips/stings_text__date_numbers_io-I.htm (2 of 7) [2002-02-27 21:19:16]