Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check if file is empty javascript fs

if (fs.exists('myfile.txt')) {
    if (fs.read('myfile.txt').length === 0) {
        console.log("File is Empty")
    } else {
        return JSON.parse(fs.read('myfile.txt'));
    }
}
 
PREVIOUS NEXT
Tagged: #check #file #empty #javascript #fs
ADD COMMENT
Topic
Name
9+3 =