All Questions

409
votes
5answers
163380 views

Why is “while ( !feof (file) )” always wrong?

I've seen people trying to read files like this in a lot of posts lately. Code #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { char * path = argc > 1 ? a...
3810
votes
48answers
2165580 views

How do I include a JavaScript file in another JavaScript file?

Is there something in JavaScript similar to @import in CSS that allows you to include a JavaScript file inside another JavaScript file?
1113
votes
27answers
1012929 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? ...
639
votes
17answers
368264 views

Is there a way to check if a file is in use?

I'm writing a program in C# that needs to repeatedly access 1 image file. Most of the time it works, but if my computer's running fast, it will try to access the file before it's been saved back to th...
1453
votes
31answers
2247222 views

How do I read a file line-by-line into a list?

How do I read every line of a file in Python and store each line as an element in a list? I want to read the file line by line and append each line to the end of the list.
506
votes
16answers
723343 views

"Cross origin requests are only supported for HTTP." error when loading a local file

I'm trying to load a 3D model into Three.js with JSONLoader, and that 3D model is in the same directory as the entire website. I'm getting the "Cross origin requests are only supported for HTTP." err...
564
votes
16answers
252155 views

Create a file in memory for user to download, not through server

Is there any way I can create a text file on the client side and prompt the user to download it, without any interaction with the server? I know I can't write directly to their machine (security and a...
1041
votes
8answers
1060564 views

How do you append to a file?

How do you append to the file instead of overwriting it? Is there a special function that appends to the file?
98
votes
14answers
35537 views

Natural Sort Order in C#

Anyone have a good resource or provide a sample of a natural order sort in C# for an FileInfo array? I am implementing the IComparer interface in my sorts.
108
votes
8answers
143911 views

Reading a resource file from within jar

I would like to read a resource from within my jar like so: File file; file = new File(getClass().getResource("/file.txt").toURI()); BufferredReader reader = new BufferedReader(new FileReader(file));...

Previous Next