input 1 « Operation « Java I/O Q&A

1. Java file input as command line argument

How do you process information in Java that was input from a file. For Example: suppose you have a file input.txt. The contents of this file is: abcdefghizzzzjklmnop azzbcdefghijklmnop My ...

2. Command Line Pipe Input in Java

Here is a simple piece of code:

public class Read {
 public static void main(String[] args) {
     BufferedReader f = new BufferedReader(new InputStreamReader(;

3. is it possible to do this on a input type ="file"?

I need to pass the filename of a file-input to a parent page... is this even possible? The input type ="file" has a value, but can I use it like this? I have ...

4. Reading from input file in command line

This time I have a very lame problem, which was working perfectly but now its not:

        BufferedReader br = new BufferedReader(new InputStreamReader(

5. How can I force a SAX parser to use a DTD if one is not specified in the input file?

How can I force a SAX parser (specifically, Xerces in Java) to use a DTD when parsing a document without having any doctype in the input document? Is this even ...

6. Running a Java program with input from a file

I am writing a program that reads the input from a file and then prints it to the screen. When I run it without taking the input from the file, it ...

7. How to read integer value from the standard input in Java

What class can I use for reading an integer variable in Java?

8. Read from a delimited input file and populate a table

I have to read from a ^ delimited file and then pulate a table. Table has nullable integer columns. When there is no value specified in the input file, the column ...

9. Java -- Read from std input, one char at a time

I'm having trouble determining the best way to read some input in for a java program. It needs to read in the individual characters of a roman numeral, and then perform ...

10. Handling multiple file input mechanisms gracefully

I'm currently refactoring a library for internal use in Java. The library receives an XML document, and returns a Result data structure. Given that:

  • There are two clients for this library, one has the ...

11. Typing input in by hand works. Using input file causes infinite loop?

I'm currently working on a programming assignment for school. It's a simple text-based RPG. When I test the program locally (by hand), it works correctly. However, when I submit it to ...

12. Is it possible to create Java enums based on input file?

I'm using Java 6. Suppose I have a file availableFruits.txt

Suppose I want an enum FruitType that contains values listed in availableFruits.txt, will I be able to do this?

13. FileInput Help/Advice

I have a fileinput class. It has a string parameter in the constructor to load the filename supplied. However it just exits if the file doesn't exist. I would like it ...

14. file input from the user

I was trying to take the input of the filename from the user and then proceed to doing all the calculations. but it keeps returning me an error. the file exists ...

15. File input in Java

I simply want to add some text on my JTextPane and I'm having the following problem: I am using the file class to load an external textfile:

File file = new File("/my/program/pics/mytext.txt");

but the problem ...

16. Issue reading input from Java

I am trying to write a method that prompts a user for input on the command-line and reads their input as a String from stdin and returns in. The first time ...

17. File Input in Java

I'm writing up a program that goes into a basic .txt file and prints certain things. It is a comma-deliminated file. The file includes 7 first and last names, and also ...

18. competitive programming and input

hello all
I'm practicing for a competitive tournament that will be in my faculty in a few weeks, and thus I encountered a small problem.
The competition restricted the use of* (except ...

19. placing a input file relative to prgram

In my program(simple plain cosole app) am reading a file a.txt. Now i will be giving the program to someone else and he should be able to run it. I dont want ...

20. JAVA: IO new File(filename) throwing "Can't read input file!"

I'm trying to create a file from one server to another. Server A executes script which needs to create a file one server B. Server A has a script that creates folder ...

21. How to tokenize an input file in java

i'm doing tokenizing a text file in java. I want to read an input file, tokenize it and write a certain character that has been tokenized into an output file. This ...

22. Some input files use or override a deprecated API

I just downloaded the new LWUIT 1.5 and when I compiled my project then I saw in the output trace these lines :

Note: Some input files use or override a deprecated ...

23. Request File Name as Input --Java

My code at the moment:

import java.util.*;

public class Percolation {
    // given an N-by-N matrix of open sites, return an N-by-N matrix
    // of sites ...

24. Need to create a user based input file

I am a student trying to finish a lab assignment.
I have two files, and but I'm confused about filling in the public String findWord() method and public String ...

25. Java input procedure

What is the procedure to take an integer input from the user with:

 BufferedReader br = new BufferedReader(new InputStreamReader(;

26. Getting accurate int and String input

I am having trouble reading in strings from the user after reading in an int. Essentially I have to get an int from the user and then several strings. I can ...

27. SWIG Configuration to Handle a FILE * C input Parameter in Java

How would you configure the SWIG .i file to handle the C FILE * type? The below function sets a file so that log output can be written to it. ...

28. Reading input from terminal

I' m writing a program that takes input from a teriminal window. The program use textbased menus. Eks. M e n u ------- 1. Show status 2. Edit ...... 3. Delete ...... 4. Exit program Choice: 1 How can I avoid to hit "Enter" each time a selection is made? - new programmer

29. regarding the input from the user

Construct some other convinent Reader from For example if I want to read data line by line BufferedReader bin=new BufferedReader(new InputStreamReader( Now I can call String dataRead=bin.readLine(); If you want to read integers, floats then use DataInputStream. Is it not comfortable to you??? I feel it is very very comfortable than C or C++. For any doubts, I'm ready to ...

30. read int inputs

hi, try the following code instead - its similar to urs. there are so many ways of doing this. this one comes to mind. import*; public class demo { public static void main(String s[]) throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(; int x,y,z; System.out.println("Enter no "); x=Integer.parseInt(in.readLine()); System.out.println("Enter no "); y=Integer.parseInt(in.readLine()); z=x+y; System.out.println("sum =" + z); } }

31. HELP with input

I have a program where i want to get four digits from the user running from console. Also if the user hits escape i would like to exit the program. I have yet to come across something that will let me get input without hitting enter. Any help would be appreciated. Thanks RyanJ

32. need help with writing user input to file

Hello, I am trying to take user input (customer info such as name, address, phone number , etc. from many text fields - I use enter to go to next text field as they are set up in a grid layout). This is done in one class and when you click the "Save" button in the frame I want to write ...

33. Input data

34. Character by Character input

Hi I just wanted to know if it is possible to get input character by character and then display it on the screen.Im right now working on a calculator like program which uses a similar LED display system. It requires the user to enter the numbers (digit after digit) and display it on the LED Panel as and when a keystroke ...

35. how to read char by char input from stdin?

Sorry for this newbie type question, but all the examples I've seen in java requires the input to be confirmed by hitting the enter key before it it reads the input. I need the input to be read as it is typed. Can someone give me some pointers as to how that is done? ie, instead of: input: a(enter) output: a ...

36. input

37. ? return value of read() when end of buffer reached, but more input pending

i am hoping someone can explain what happens in the following scenario: say there is a BufferedReader that is open on an input source, such as a file or stream. another application is writing to the source as the BufferedReader is reading from it, but there may be pauses between write operations. (imagine a client sporadically sending messages to a server, ...

38. User input does nothing

Hi people. I have a few problems at the moment. Below is my incomplete program. It compiles but doesn't do a whole lot when run. I am doing a project on polymophism and inheritance. I have a footwear class(parent) and sneaker & thong classes(children) switch statements don't do anything. I'm trying to setColour to "something"(eg: whatever option user chooses), then it ...

39. Reading input from a file

Hi all! I need to get some input from a file and process the input in an application. The input could be ---- 1 2 3 12 3 4 ---- And I have to print the integers My approach: import*; public class MyApp { public static void main(String[] args) throws Exception { File inputFile = new File("f.txt"); FileReader in ...

40. Java input

Hi, im trying to write a java program that allows for conversions to different bases. The conversions aren't the hard part its the input that is giving me trouble. I can only use for my input. I was hoping someone could help me and show me how this is done because when i input the number i get the ascii ...

41. How to remove line-termination character after input

When getting user input, Pressing Enter terminates user input and sends the input data to the inputstream. But, it causes a newline to be printed although readline() does not return the line-termination character. BufferedReader br = new BufferedReader(new InputStreamReader(; String[] xvalue = new String[5]; for(int i=1; i <= 5; i++){ System.out.print("x" + i + " = "); xvalue[i] = br.readLine(); System.out.print(" ...

42. Command line Input

43. keyed input file

I'm working on a program in which certain objects have a variable that changes with each time step. I'd like to use an input text file that uses the tick number (or some other index) as a key for the value of that variable for that specific object at that time step. The file will not change at all during the ...

44. Getting String input from file

OK, this is supposed to be easy, still I could not find the answer in google or searching this sub-forum. Please help. My problem in simple form, I have a text file that has two lines: this/is/line/1 this/is/line/2 i have two variables in my program var1 and var2. how do I get the values of those two lines, into my two ...

45. Will these methods wait for input?

It all depends on the underlying stream. Ultimately, either one of these has to call on some InputStream. If that read() call blocks, then the methods you've shown will block as a result. In most cases, as long as an InputStream isn't in an "end-of-file" state, read() will block and wait for input.

46. How to automate user inputs to a Java program

Hi, We have a Java program which prompts user for 4 or 5 inputs one after the other and then does its computation. The inputs are mostly file names and folder paths. I am trying to figure out a way of automating these inputs. We don't want to (and can not) change the program to read inputs from a file. We ...

47. Get name of input file (at commandline )

Hi, When i'm calling a program, for example java Test

48. How to take input from screen automatically

I want the input from console but value should not be entered by user e.g BufferedReader buff = new BufferedReader(new InputStreamReader( )); System.out.println("Enter text"); buff.readLine(); Here user is not allowed to enter text.So , how program will get the text ? Necessary condition is input should be taken from console only .

49. core java program needs input

It depends on the input. If it's something singular and short then a command line argument would be the easiest. If one questions given depend on the answers already given then I would prompt the user while the program is executing. If I wanted to be able to pipe the data to the program from the output of another's output then ...

50. input type = file problem

Hi You can to use hidden field in your form When you submit, you use JavaScript to get your fileName And then, in your servlet, you must use mutilPart.getParameter() to get your fileName Example: In your HTML file