Just wondering if you could help me out a bit with netBeans (the help file is no good at this).
What i want to do is just write a simple java program that takes input. Now i know how to pass arguments on their own (Build > Set Arguments) which works as if the user was typing the arguments at the command prompt, but i need to be able to do the same but the program should read from a file. Basically when you use the command prompt you would type 'java javaFile fileToPass.txt' to make the javaFile read input from fileToPass.txt (obviously its been compiled first).
However, i have got some problems at command prompt and would prefer to just use netBeans to read from a file.
Does anyone know how i can do this in netBeans.
I don't do netBeans, but perhaps I can ask a question to help clarify for others what the exact thing you need help with...
Is the question basically, "How do I read a file using netBeans?"
Or do you actually know how to read a file, but you're looking for a way to use it as a substitute for command line arguments? (In which case, I'd suggest using XML for the file and storing the info in the form of parameter name + parameter value. Then parse out the parameters and associated values, if any, and take the appropriate action.)
What I'm suggesting is that you use XML for the formatting of the file you read the parameters from.
You could read in values from the XML file sequentially, which would correspond to using commandline parameters that were used by their order: foo.exe 1 blah
Or you could assign names and values to parameters, giving you much more flexibility and corresponding to a command line where parameters have a name specified first, followed by their value: foo.exe -count 1 -word blah
Oops I am sorry, I think I read your sentence about :
'Or do you actually know how to read a file, but you're looking for a way to use it as a substitute for command line arguments? '
rather lightly. I dont actually know how to read a file (of inputs) that java should look in. I was thinking more along the lines of do i know how to open a java file in netBeans (like you would in Microsoft word or something), i know it sounds rather ignorant :-D
Let me put it as simple as i can, when you run some java program that you have made that prompts you to input some value(s) what you would do at that point (when it prompts you) is to type it in. Instead of typing in the values manually i would like to put them in a file (for example if there are many values and i dont wish to type them in or paste them everytime). Then i can use the command
java someJavaFile < someFileToRead
i cant remember for sure whether its < or > but its to that effect.
Then what java will do is to take (when it prompts) the inputs from that file (every line is like typing at a new prompt - i can set it up that way) as if it was an input from you physically typing it at the keyboard. I would just like to know how you can do this in netbeans or if it is at all possible to do it in netBeans since you can do it at the command prompt.
Thank you and sorry for the trouble.
For command line standard IO redirection:
< is input
> is output
I know practically nothing about netBeans, so I can't really be of much help...
I still am somewhat confused by exactly what you're looking for... Do you mean that for just one component (netBean), you want to be able to redirect standard input to come from a file? Just that component, and not the rest of the application it is used in?
Hmmm... Maybe I get it now... is the netBean a GUI component, not using a console? In which case, I have no idea if you can redirect input. However, if nothing else, you should be able to slap together an ad hoc solution along the lines of what I proposed earlier.