How to take input form both text file and key board
Hi:
I have some problem as concering about taking input form both text file and key board at the same time . In my main class, some of input is from text file while some is from key board. How do I let the readLine() method to distinguish my command? Also the same thing for output.In the same class, some output to DS-command ,while some write to a text file . How to do that?
Thank you for your offer!
carol
[441 byte] By [
xwuc] at [2007-9-26 1:19:34]

Hmmm... If I understand you correctly, you want to take in information from a file and keyboard at the same time. Is the keyboard triggering the file reader? One thing you can do is have two BufferedReaders. Name one something like "keyin" and the other one "filein" or something to that effect. Like this:
BufferedReader keyin = new BufferedReader(new InputStreamReader(System.in));
BufferedReader filein = new BufferedReader(new FileReader("filename.ext");
Now you have two readers to take in input from keyboard and file. You can use "String variable = keyin.readLine();" for reading from the keyboard and "String variable2 = filein.readLine();" for reading from the file.
For output to a file, you can use a PrintWriter.
PrintWriter output = new PrintWriter(new FileWriter("filename2.ext"));
So when you want to output to a file and command line (which I think is what you mean by DS-Command) all you need to do is...
System.out.println("Command line output"); //Will appear on screen in the command line.
output.println("File output"); //Will appear in file.
output.close(); //When you're finished writing the file.
I hope this helps!
Ed
PS: If you need any more help or information, feel free to contact me. (edelm@nortelnetworks.com)
edelm at 2007-6-29 0:52:15 >

i'll give a simpler answer.1.use "System.in(...)" for input from the DSPrompt, and "System.out(...)" for output.2.use the File class object(or a BuffererReader/Writer) to input/output to the file.this should work and good luck.sam