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
0
votes
2 answers
File.createTempFile in Java getting Incompatible type error
Till now my code works fine where I am creating file in temporary directory and processing it.
But now I am trying to provide specific directory where I actually want to create xml file. So in method createTmpXmlFile
private static Path…

Andrew
- 3,632
- 24
- 64
- 113
0
votes
1 answer
why is my search function for file handling(.txt file) not working?
I want to search the structure (and print other details of book) I have added for the book for a particular issueNumber entered by user in the .txt file.
When I run the code it terminates after asking for user input (issueNumber-issuenumber).
I…

KARAN GUPTA
- 61
- 7
0
votes
1 answer
Delete files before creating new from temp using Java file method
I have below code where i am trying to create new file in temp directory which is xml file and its working fine.
Now everytime i run the code, i want to delete the previous xml file from this temp directory before creating new xml file because of…

Andrew
- 3,632
- 24
- 64
- 113
0
votes
2 answers
Python: filename matching using regex
I have written this code
import os
from datetime import datetime
import re
now = datetime.now()
filename = now.strftime("%Y%m%d%H%M") #For example 202006191839
for fname in os.listdir(downloadPath):
if re.match('export_' +…

SirLancillotto
- 49
- 8
0
votes
0 answers
c++ read comma separated file in variable
I have string in text file with comma separated value and i am reading comma separated value in different variable as doing below
ifstream file("example.txt");
int age, count;
char name[50]="\0";
char degree[50] = "\0";
while…

Azeem Hafeez
- 250
- 4
- 14
0
votes
3 answers
Is there a way to print all string in capital letters without using strupr function as its not a standard library function?
I want to print the data stored in a file which is randomly cased in all caps and strupr() seems to be something that's been listed by someone previously but its not a standard function and may not be cross platform. Is there something which is…
user13695064
0
votes
0 answers
Having problem with simple C++ file handling program
My code is not working as expected. When I run the program and try to output n ( on line ABC ) , the program displays only "New" on the screen. why isn't the program reading the rest of the file? Any help will be appreciated. Thanks
#include…

Anon 123
- 73
- 5
0
votes
1 answer
How to read a file at compile time in C++?
I have been trying to look for a way to store files as const char* at compile time.
I tried doing this:
#define STRINGIFY(...) #__VA_ARGS__ // va args deals with commas
#define INCLUDE(path) #include path // error: '#' is not followed by a macro…

MaximV
- 155
- 11
0
votes
1 answer
How to read file, convert binary buffer to binary string and later convert the binary string to binary buffer again in python?
I opened a file (.jpeg) in binary format and stored it's content in a variable and converted the binary buffer into string using str(). Now, I want to convert the string into binary buffer again.
from tkinter import filedialog
file_path =…

Divyanshu Gupta
- 103
- 6
0
votes
1 answer
how to open a directory using its d_name
I list the directories and then want to open the d_name of one of the entries.For this, I input an integer i.e. the number of the item in the list. and open it's corresponding file.
I'm getting this error:
[Error] request for member 'c_str' in…

anonymous38653
- 393
- 4
- 16
0
votes
1 answer
how to find the coordinates of a searched string using regex in the file?
Actually my aim is to find a string in a file in python, I used regex to find it, I found it also but don't know how to calculate the coordinates of the position of that string in the file? I have no idea about it how to progress further
user13732919
0
votes
3 answers
What is the difference between "\" and "/" used in file path in a java program?
I wanted to know the difference between "\" and "/" used in file path in a java program and also the difference between "\" and "\" used in file path.
0
votes
2 answers
Text File Returns Blank Using readline() In Python on Windows
I'm in the middle of a tutorial that has a seemingly simple task of reading a file but one of the tests to check the file seems to be failing.
employee_file = open("employees.txt", "r")
print(employee_file.readable()) # this returns "True" to the…

BSimmons
- 7
- 2
0
votes
1 answer
This code snippet is storing the value of input with a '\n' which is not letting it match with the other string with same input but without '\n'
I am trying to match the input of a string by user with that of the string from a file. But there are two things that is not happening the right way.
typedef struct
{
int yyyy;
int mm;
int dd;
} Date;
int main()
{
FILE *fp2;
…
user13695064
0
votes
0 answers
How to use try and error for user Input, if error it will not delete the text file content in python?
If the User Input in mark() funtion is string not integer the list.txt content will delete and if it's true also it will delete the content
then after i want to return to main() funtion
Example:
Enter a number to mark: g
Invalid Input!//the…

Newbieee
- 167
- 10