Questions tagged [file-handling]

file-handling is an abstraction of common actions such as creating, opening, closing, reading, updating, writing, comparing and deleting files

2915 questions
26
votes
4 answers

use of deleteOnExit() method in java

what is the difference between delete() and deleteOnExit() methods in java.io.File class in Java?
Vishal Chugh
  • 337
  • 1
  • 6
  • 12
25
votes
5 answers

How to find EOF while reading from a file

I am using the following code to read a file in Go: spoon , err := ioutil.ReadFile(os.Args[1]) if err!=nil { panic ("File reading error") } Now I check for every byte I pick for what character it is. For example: spoon[i]==' ' //for…
Worlock
  • 406
  • 1
  • 4
  • 15
25
votes
3 answers

Modifying a text file in a ZIP archive in Java

My use case requires me to open a txt file, say abc.txt which is inside a zip archive which contains key-value pairs in the form key1=value1 key2=value2 .. and so on where each key-value pair is in a new line. I have to change one value…
Prabhakar
  • 347
  • 1
  • 5
  • 12
23
votes
3 answers

What is ios::in|ios::out?

I was reading some project code and I found this,here MembersOfLibrary() is a constructor of class MenberOfLibrary class MembersOfLibrary { public: MembersOfLibrary(); ~MembersOfLibrary() {} void addMember(); void removeMember(); …
KidWithAComputer
  • 311
  • 1
  • 2
  • 10
21
votes
6 answers

mkdir() is not creating the new directory

I am using Eclipse and jdk1.7. I am making a basic program using file handling, in which an output directory inside the directory is to be made. But when I run the program, the output is showing false and the directory is not made. I thought that…
user2529216
  • 493
  • 1
  • 3
  • 11
19
votes
3 answers

How can I handle File Uploads in a Microservice Environment?

I am in the process of trying to make a decision on how, when and where to handle uploaded files from users. We are in a MicroService environment (PHP + Linux) for a new system to be deployed in the coming months. One key component is incoming…
SeaFuzz
  • 1,177
  • 9
  • 28
16
votes
1 answer

How to check whether ifstream is end of file in C++

I need to read all blocks of one large file(about 10GB) sequentially, the file contains many floats with a few strings, like this(each item splited by '\n'): 6.292611 -1.078219E-266 -2.305673E+065 sod;eiwo 4.899747e-237 1.673940e+089 -4.515213 I…
user1024
  • 982
  • 4
  • 13
  • 26
16
votes
2 answers

Why do I get a SIGABRT here?

I have this code segment in which I am opening/closing a file a number of times (in a loop): for(i=1;i
user59634
16
votes
1 answer

Reading all files in all directories

I have the code working to read in the values of a single text file but am having difficulties reading all files from all directories and putting all of the contents together. Here is what I have: filename = '*' filesuffix = '*' location =…
Relative0
  • 1,567
  • 4
  • 17
  • 23
16
votes
1 answer

Write to a file in Perl

Consider: #!/usr/local/bin/perl $files = "C:\\Users\\A\\workspace\\CCoverage\\backup.txt"; unlink ($files); open (OUTFILE, '>>$files'); print OUTFILE "Something\n"; close (OUTFILE); The above is a simple subroutine I wrote in Perl, but it doesn't…
Daanish
  • 1,061
  • 7
  • 18
  • 29
15
votes
2 answers

How can I use file_put_contents() with FILE_APPEND | LOCK_EX safety?

I'm using: file_put_contents("peopleList.txt", $person, FILE_APPEND | LOCK_EX); To write to the end of a file and to make sure no one else (or script) is also writing to the same file at the same time. The PHP manual says it will return a falsy…
hozza
  • 619
  • 2
  • 12
  • 27
15
votes
3 answers

Can BufferedReader read bytes?

Sorry if this question is a dulplicate but I didn't get an answer I was looking for. Java docs says this In general, each read request made of a Reader causes a corresponding read request to be made of the underlying character or byte stream. It is…
TruePS
  • 493
  • 2
  • 12
  • 33
15
votes
2 answers

How feof() works in C

Does feof() checks for eof for the current position of filepointer or checks for the position next to current filepointer? Thanks for your help !
Alfred James
  • 1,029
  • 6
  • 17
  • 27
13
votes
4 answers

C Win32: save .bmp image from HBITMAP

I am working with a framegrabber and need to get the images from computer memory and save them on an image file. after trying for couple of days I end up with the following 2 functions, which creates a file and windows OS is able to run the .bmp…
user261002
  • 2,182
  • 10
  • 46
  • 73
12
votes
3 answers

Python write to hdfs file

What is the best way to create/write/update a file in remote HDFS from local python script? I am able to list files and directories but writing seems to be a problem. I have searched hdfs and snakebite but none of them give a clean way to do this.
nishant
  • 896
  • 1
  • 8
  • 27