Please support our Java advertiser: Lunarpages Java Web Hosting
![]() |
•
•
Join Date: Sep 2007
Posts: 36
Reputation:
Rep Power: 2
Solved Threads: 1
I'm getting further and further to figuring out how my java program can read from my console application written in vb.net, i have some of my class here that i found on a site:
This is mainly to do with reading numbers from input but il change it later.
This reads input from my console application but how do i call it from my main process so that the user can type away into the console and the java program picks up the input and then puts it into a string.
I know if this seems basic but I'm really not that good with java, I'm mainly used to programming in vb, vb.net and C#.
This is mainly to do with reading numbers from input but il change it later.
java Syntax (Toggle Plain Text)
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.text.DecimalFormat; import java.text.ParseException; public class InputHandler{ public static void main(String[] args) { System.out.println("Reading from console."); double numberFromConsole; try { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); String s = br.readLine(); DecimalFormat df = new DecimalFormat(); Number n = df.parse(s); numberFromConsole = n.doubleValue(); } catch (IOException e) { numberFromConsole = 0; } catch (ParseException e) { numberFromConsole = 0; } System.out.println(numberFromConsole ); } }
I know if this seems basic but I'm really not that good with java, I'm mainly used to programming in vb, vb.net and C#.
Compile it, I think if you are console the command is >javac InputHandler.java (if I remember correctly because for a very long time I have been using IDEs) and run it with the command
>java InputHandler
Then the program will print the message in your code and then just insert the input.
>java InputHandler
Then the program will print the message in your code and then just insert the input.
I AM the 12th CYLON
![]() |
Similar Threads
Other Threads in the Java Forum
- Finding length (Java)
- Console Window Code (Java)
- Scanf Equivalent (Java)
- reading a same input twice from the console (C)
- Input Buffer (C)
Other Threads in the Java Forum
- Previous Thread: Array/BinaryTree/HashTable
- Next Thread: Date Help
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)





thanks allot! this is going to allow me to do so much more then i used to be able to do.
Linear Mode