Questions tagged [writefile]

For questions about writing to a file. It could be referencing appending data, rewriting all existing content, or other related uses of functions that programmatically edit files. It is not limited to a certain language.

This tag is most often used when someone wants to add/insert content to a file programmatically. One example is in the Node JS function fs.writeFile, which is used to create files and write to them.

This is an example script which shows the usage of fs.writeFile to write a string to message.txt.

// Node JS

const fs = require('fs');
const data = new Uint8Array(Buffer.from('Hello Node.js'));

fs.writeFile('message.txt', data, (err) => {
  if (err) throw err;
  console.log('The file has been saved!');
});

Make sure to pair this tag with a language tag as is generally not specific enough to describe a complete question.

494 questions
2
votes
2 answers

does WriteFile post a completion packet on finishing immediately when using io completion ports

I know that when WSARecv is used with it may finishes immediately and in such case a completion packet will still be posted and this behavior can be altered using SetFileCompletionNotificationModes but I want to know the case for files and pipes…
dev65
  • 1,440
  • 10
  • 25
2
votes
1 answer

Java -- How do I call a method using args[]?

Problem: I don't know how to appropriately call the method like the assignment instructs me to. Objective: Within the main method, call the readFile method with the first command line argument (args[0]), then call the writeFile method with the…
FoxH
  • 45
  • 8
2
votes
1 answer

C# Threads read and write files

I am trying to do something like this: I have 3 files which contain strings read 3 files and create a 4th file which contains the 3 files content the reading is suppose to be done with threads which will run in parallel 4th thread to write for the…
Tal
  • 29
  • 3
2
votes
2 answers

Is it possible to write data in a output file in parallel

Is it possible to write data on a single output file with more processors. I mean consider some processors have a part of a data (e.g. a matrix) and the whole matrix should be written in a single output file. Is it possible each processors write own…
mehdi_bm
  • 381
  • 1
  • 3
  • 16
2
votes
4 answers

How can I write to a file and remove the file afterwards in C#?

I need to create a file, write one line of text in the file and then delete the file and estimate how long it will take to do it. Unfortunately, I am running in couple of problems, first I cannot write in the file, it succesfully creates it but…
grozdeto
  • 1,201
  • 1
  • 13
  • 34
2
votes
1 answer

How to write into a single file through multiple classes in Java?

I am trying to write into a single text file through different classes. I opened the text file from the main class: public static void main( String[] args ) throws Exception { BufferedWriter writer = new BufferedWriter(new…
AURRR
  • 23
  • 2
2
votes
0 answers

VBScript to compare each line of string to each line of text file and make replacements

I'm making a little .srt translator tool that will scrape each text line of a .srt file, translate via google translate, and make the replacements into a new file. I've got everything done except for make the actual replacements. Seems like it…
Drivium
  • 537
  • 6
  • 24
2
votes
1 answer

How to write big file efficiently in Haskell

Hello i am trying to write a ~1GB file in a timely manner.Is there any recommended method.Up until now the process takes somewhere in the order of tens of minutes . Am i wrong in using Text should i use ByteString ? (I have also used String) …
Bercovici Adrian
  • 8,794
  • 17
  • 73
  • 152
2
votes
0 answers

Create .txt file with encoding UCS-2 LE BOM OR Unicode

Hi everyone i am Adobe Extension developer, i stuck on creating a new text file with having encoding option "UCS-2 LE Bom" or "Unicode". In my extension node js is enabled, using node js i successfully creating txt file with default encoding (UTF-8)…
Shiva
  • 21
  • 6
2
votes
1 answer

Default java file.encoding is Cp1252 but created file is ISO-8859-1

I checked the default file encoding in jvm: System.out.println("***file.encoding::" + System.getProperty("file.encoding")); // ***file.encoding::Cp1252 But when I wrote new file using FileWriter: bf = new BufferedWriter(new…
2
votes
3 answers

Python 3+, Read In Text File and Write to New File Excluding Range of Lines

I'm using Python version 3.6 on a Windows machine. I'm reading in a text file using with open() and readlines(). After reading in the text file lines, I want to write certain lines to a new text file, but exclude certain ranges of lines. I do not…
probat
  • 1,422
  • 3
  • 17
  • 33
2
votes
2 answers

cannot write(2) file larger than 2GB (up to 2TB)

I have a program written by C. It computes something and writes the output into a file. My problem is that it does not write more than 2GB. Let me put a simplified code. #include #include #include #include…
Jihyun
  • 883
  • 5
  • 17
2
votes
2 answers

WriteFile with Windows Sockets returns invalid parameter error

I've been struggling with Windows Sockets for two days not being able to just use write to socket as in Linux it is. I want to write my own shellcode and I'm playing around how to redirect stdout, stdin to socket handle (that's where my playings…
Domin568
  • 31
  • 8
2
votes
0 answers

Write file to absolute path outside of app directory [Node.js]

I'm trying to create and write to a file in a folder outside of node app's source folder. I have a absolute path like this E:\myFolder\ but when I try to writeFile with fs it throws ENOENT error. I've created E:\myFolder manually, but I think the…
kecman
  • 813
  • 3
  • 14
  • 34
2
votes
1 answer

Repeated Writing and Loading ArrayList of objects from a file

I have a 'Person' class where i stored data like name, surname etc. I make 5 object type Person, add them to ArrayList, and save this ArrayList to file. Next i'm loading from this file ArrayList and i have 5 person. Problem is when i want save again…
twistezo
  • 512
  • 1
  • 11
  • 24