I use JavaScript and node. I need to read the raw bytes from the file.
I create a Uint8array and fill it with data from a file using fs.Read.
Then I output the data to the console of the array as a whole, and individual elements.
Instead of the values of the elements, I get zeros.
But it is clear that the array has non-zero data.
var buf1 = new Uint8Array( 4 );
fs.open( filePath, 'r+', function ( err, fd ) {
if (err) { console.error( err ) };
fs.read( fd, buf1, 0, buf1.length, 4,
function (err, bytes) {
if (err) { console.log(err) };
fs.close( fd, function (err) {
if (err) { console.log(err) };
}) }) });
console.log( buf1 );
console.log( buf1[0] );
console.log( buf1[1] );
console.log( buf1[2] );
console.log( buf1[3] );
var buf2 = new Uint32Array( buf1.buffer );
console.log( buf2 );
console.log( buf2[0] );