|
-
Jan 30th, 2007, 11:14 AM
#1
Thread Starter
Frenzied Member
how to read an input from the main method
at the top of my class i have
private static String SECRET_KEY = "";
how do i read a key and set it to SECRET_KEY?
if (SECRET_KEY == "") {
System.out.println("Please enter a secre key which both the client and server will share:");
}
-
Jan 30th, 2007, 11:16 AM
#2
Re: how to read an input from the main method
Through System.in. You might want to wrap an InputStreamReader and a BufferedReader around it to read a single line of input.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 30th, 2007, 12:43 PM
#3
Thread Starter
Frenzied Member
Re: how to read an input from the main method
 Originally Posted by CornedBee
Through System.in. You might want to wrap an InputStreamReader and a BufferedReader around it to read a single line of input.
Thanks bud. any chance you can give me an e.g
-
Jan 30th, 2007, 12:57 PM
#4
Re: how to read an input from the main method
Code:
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
String line = r.readLine().trim();
Some stuff to import from java.io.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 30th, 2007, 01:03 PM
#5
Thread Starter
Frenzied Member
Re: how to read an input from the main method
-
Jan 30th, 2007, 01:05 PM
#6
Thread Starter
Frenzied Member
Re: how to read an input from the main method
so i just simply do
SECRET_KEY = line;
?
-
Jan 30th, 2007, 03:49 PM
#7
Re: how to read an input from the main method
Yeah, or you read directly into SECRET_KEY.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|