file-handling is an abstraction of common actions such as creating, opening, closing, reading, updating, writing, comparing and deleting files
Questions tagged [file-handling]
2915 questions
4
votes
4 answers
how to set read only access for file using java
How to set read-only access for a file that's been created and written using java InputStream API.

Shmily Nguyễn
- 41
- 1
- 5
4
votes
3 answers
How do I open a file whose full name is unknown with Perl?
I want to know if there is anything that lets me do the following:
folder1 has files "readfile1" "f2" "fi5"
The only thing I know is that I need to read the file which starts with readfile, and I don't know what's there in the name after the string…

jerrygo
- 607
- 2
- 8
- 14
4
votes
5 answers
Creating a file using fopen()
I am just creating a basic file handling program.
the code is this:
#include
int main()
{
FILE *p;
p=fopen("D:\\TENLINES.TXT","r");
if(p==0)
{
printf("Error",);
}
fclose(p);
}
This is giving Error, I cannot create files tried…

Popeye
- 41
- 1
- 1
- 3
4
votes
3 answers
Rename file from outside when it's opened in Java
I'm coding a Java Application right now and it has to read through a file.
I'm using this method to do so:
BufferedReader mb_reader = new BufferedReader(new FileReader(f1));
int lines = 0;
while (null != (mb_line = mb_reader.readLine())) {
…

JetStream
- 809
- 1
- 8
- 28
4
votes
3 answers
Is it necessary to close a file number of time it is opened in program?
If file is opened using fopen() and in different mode then is it necessary to close it number of time or it can be closed once at end of code ?

ameyCU
- 16,489
- 2
- 26
- 41
4
votes
2 answers
How to update data at a particular line in a file?
Consider i have following file ("testt.txt")
abc
123
def
456
ghi
789
jkl
114
Now if i wanted to update the figure next to name ghi (i.e. 789),
how would i do it?
The following code helps me reach there quickly no doubt, but how to update it…

bikrathor
- 96
- 1
- 1
- 7
4
votes
1 answer
zip creation error in java
I am using ZipOutputStream,FileOutputStream and FileInputStream.
First I created a folder with one file. It successfully created. Then I tried to create zip files. Dynamically, it creates file first time correctly but at second time , third time it…

Chaitanya Joshi
- 304
- 1
- 4
- 22
4
votes
3 answers
Python context for file or None
Python is going to call a subprocess, the user either requested that subprocesses stdout is to go to a file (or back-holed to os.devnull), or the subprocesses output is to be passed though "in real time".
My current best guess as how to do this…

ThorSummoner
- 16,657
- 15
- 135
- 147
4
votes
2 answers
Load a large text file into a string
I'm looking to load a 150 MB text file into a string. The file is UTF16 encoded, so it will produce a string that's about 150 MB in memory. All the methods I have tried result in an Out of Memory exception.
I know this is a huge string, and…

Nathan
- 1,591
- 4
- 17
- 22
4
votes
2 answers
How do I load resource using Class Loader as File?
I want to open files using the class loader. However I always get a FileNotFoundException. How do I create a new File using the URL? I don't want to open it as a stream just as a file.
URL url =…

unj2
- 52,135
- 87
- 247
- 375
4
votes
1 answer
Read comma separated values from a text file in C
I am really new to C programming and this is a part of an assignment. I am trying to read a comma separated text file in the format:
[value1], [value2]
in C and trying to pass them as string and int parameter into a function. I have tried using…

Souradeep Sinha
- 121
- 1
- 1
- 10
4
votes
3 answers
Delete last 4 bytes of a file without opening the file?
This is a question which was asked to me in an interview and still could not find a way to do it-
Suppose I have a .txt file and I want to delete the last 4 characters from the content of that file without opening the file. The first question is- Is…

Abhimanyu Garg
- 416
- 4
- 10
4
votes
7 answers
What's the best strategy to delete a very huge folder using Perl?
I need to delete all content (files and folders) under a given folder. The problems is the folder has millions of files and folders inside it. So I don't want to load all the file names in one go.
Logic should be like this:
iterate a folder without…

André Diniz
- 306
- 3
- 15
4
votes
3 answers
Use python to handle and create input files for external software
When I program I often use external software to do the heavy computations, but then analysis the results in Python. These external software is often Fortran, C or C++, which works by giving them input file(s). This can either be a small file telling…

Daniel Thaagaard Andreasen
- 7,986
- 7
- 31
- 42
4
votes
2 answers
SDL2 Mac File Handling
I'm having an odd problem with accessing files through SDL2 on Mac. I am using XCode 4 on OS X Mountain Lion, and I am using SDL2 as a framework. I am NOT compiling SDL2 from source. I have added the framework to the bundle, as well as the files I…

BrainSteel
- 669
- 5
- 17