Harmony Clean Flat Responsive WordPress Blog Theme

Reading text file byte by byte.in Node.js

오후 11:39 Unknown 0 Comments Category :

I tried to search how to read text file byte by byte but it was hard to search it. Most of posts shew how to read whole text file not byte by byte. Even if there are some information about the 'fs.read' in nodejs.org, that information was not enough for me because my knowledge is not enough to understand 'fs.read' with just grammar information. I googled many time to search some information how to read text file byte by byte and combined all sources what I searched. Finally, I succeed to read text file byte by byte. The code is following:





Actually, I am not sure how to use 'fs.read' for reading byte by byte because when I use fs.read, there was a error message that "fd must be a file descriptor.". I googled what this mean and how to solve it and I found another way to read byte to byte by using fs.readSync(synchronous version of fs.read). In this code, if the cursor meet the end of line(there should be \r\n if you change the line and print it by using hex). The purpose for this code is to count how many data have come to this device. 
Therefore, the result is like following:




RELATED POSTS

0 개의 댓글