All Questions

421
votes
15answers
275509 views

Scanner is skipping nextLine() after using next() or nextFoo()?

I am using Scanner methods nextInt() and nextLine() for reading input. Basically, it looks like this: System.out.println("enter numerical value"); int option; option = input.nextInt();//read nume...
532
votes
28answers
724043 views

How to append text to an existing file in Java

I need to append text repeatedly to an existing file in Java. How do I do that?
1114
votes
27answers
1013213 views

How do I create a Java string from the contents of a file?

I've been using the idiom below for some time now. And it seems to be the most wide-spread, at least on the sites I've visited. Is there a better/different way to read a file into a string in Java? ...
2960
votes
54answers
1561556 views

Read/convert an InputStream to a String

If you have java.io.InputStream object, how should you process that object and produce a String? Suppose I have an InputStream that contains text data, and I want to convert this to a String. For e...
395
votes
24answers
164471 views

Non-blocking read on a subprocess.PIPE in python

I'm using the subprocess module to start a subprocess and connect to it's output stream (stdout). I want to be able to execute non-blocking reads on its stdout. Is there a way to make .readline non-bl...
617
votes
19answers
918377 views

How to read a large text file line by line using Java?

I need to read a large text file of around 5-6 GB line by line using Java. How can I do this quickly?
455
votes
25answers
701284 views

How to read all files in a folder from Java?

How to read all the files in a folder through Java?
175
votes
17answers
212806 views

Parsing CSV files in C#, with header

Is there a default/official/recommended way to parse CSV files in C#? I don't want to roll my own parser. Also, I've seen instances of people using ODBC/OLE DB to read CSV via the Text driver, and a ...
55
votes
7answers
43839 views

Why can't I call read() twice on an open file?

For an exercise I'm doing, I'm trying to read the contents of a given file twice using the read() method. Strangely, when I call it the second time, it doesn't seem to return the file content as a str...
628
votes
19answers
857256 views

How do I check if a file exists in Java?

How can I check whether a file exists, before opening it for reading in Java? (equivalent of Perl's -e $filename). The only similar question on SO deals with writing the file and was thus answered ...

Previous Next