Created
April 7, 2016 14:28
-
-
Save alessioalex/474c05b31ba635a5938112a1efb5e7ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var CHUNK_SIZE = 4 * 1024; | |
var buffer = new Buffer(CHUNK_SIZE); | |
var filePath = __dirname + '/public/index.html'; | |
// fs.open(filePath, 'r', function(err, fd) { | |
// if (err) throw err; | |
// | |
// fs.read(fd, buffer, 0, CHUNK_SIZE, null, function(err, nread) { | |
// if (err) throw err; | |
// | |
// console.log(buffer.slice(0, nread).toString('utf8')); | |
// | |
// fs.close(fd, function(err) { | |
// if (err) throw err; | |
// }); | |
// }); | |
// }); | |
var fd = fs.openSync(filePath, 'r'); | |
var nread = fs.readSync(fd, buffer, 0, CHUNK_SIZE, null); | |
console.log(buffer.slice(0, nread).toString('utf8')); | |
fs.closeSync(fd); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment