Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
const fs = require("fs");
fs.readFile('file.txt', (err, data) => {
if (err) {
throw err;
}
let fileRows = data.toString().split('\n');
let firstRow = fileRows.shift();
fileRows.push(firstRow);
const fileData = new Uint8Array(Buffer.from(fileRows.join('\n')));
fs.writeFile('file.txt', fileData, (err) => {
if (err) {
throw err;
}
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question