diff --git "a/\346\233\276\351\235\222\345\207\244/open-write-close\344\275\234\344\270\232/bigdata/big.txt" "b/\346\233\276\351\235\222\345\207\244/open-write-close\344\275\234\344\270\232/bigdata/big.txt" new file mode 100644 index 0000000000000000000000000000000000000000..03567b102b84521af25970a2eb42a078e6af329c --- /dev/null +++ "b/\346\233\276\351\235\222\345\207\244/open-write-close\344\275\234\344\270\232/bigdata/big.txt" @@ -0,0 +1 @@ +qqdcqqqedwsxedcqqqqqqqqwsxedcqqqxedcqqqqqqazwsxedcqqqwsxedcqqqqqqqqqqqsxedcqqqdcqqqazwsxedcqqqcqqqzwsxedcqqqzwsxedcqqqqqqcqqqqqqazwsxedcqqqqqqwsxedcqqqqazwsxedcqqqdcqqqdcqqqqazwsxedcqqqsxedcqqqedcqqqcqqqsxedcqqqdcqqqqqqqqqazwsxedcqqqqqdcqqqwsxedcqqqcqqqedcqqqedcqqqcqqqsxedcqqqazwsxedcqqqsxedcqqqdcqqqedcqqqazwsxedcqqqcqqqazwsxedcqqqqazwsxedcqqqqazwsxedcqqqazwsxedcqqqxedcqqqxedcqqqazwsxedcqqqdcqqqdcqqqqqqxedcqqqedcqqqdcqqqxedcqqqcqqqsxedcqqqwsxedcqqqqqqcqqqsxedcqqqdcqqqcqqqedcqqqqazwsxedcqqqqazwsxedcqqqxedcqqqsxedcqqqsxedcqqqwsxedcqqqzwsxedcqqqdcqqqazwsxedcqqqqazwsxedcqqqzwsxedcqqqqazwsxedcqqqdcqqqqqxedcqqqazwsxedcqqqwsxedcqqqqazwsxedcqqqsxedcqqqcqqqqqqqqqzwsxedcqqqdcqqqdcqqqedcqqqqazwsxedcqqqqazwsxedcqqqqqqzwsxedcqqqcqqqxedcqqqdcqqqwsxedcqqqdcqqqsxedcqqqqqqsxedcqqqqqqqqqqazwsxedcqqqwsxedcqqqxedcqqqxedcqqqzwsxedcqqqxedcqqqcqqqqqedcqqqedcqqqwsxedcqqqcqqqazwsxedcqqqedcqqqazwsxedcqqqzwsxedcqqqazwsxedcqqqazwsxedcqqqcqqqwsxedcqqqcqqqxedcqqqqqqqqqzwsxedcqqqedcqqqqqqqqqdcqqqedcqqqazwsxedcqqqcqqqqqqqazwsxedcqqqdcqqqqazwsxedcqqqqqqcqqqazwsxedcqqqqqdcqqqedcqqqdcqqqedcqqqedcqqqedcqqqcqqqzwsxedcqqqazwsxedcqqqqqdcqqqxedcqqqzwsxedcqqqsxedcqqqsxedcqqqqqqzwsxedcqqqwsxedcqqqxedcqqqqqqqqqzwsxedcqqqcqqqwsxedcqqqqqqqqcqqqqqcqqqqqwsxedcqqqcqqqedcqqqxedcqqqwsxedcqqqdcqqqzwsxedcqqqqqqzwsxedcqqqcqqqwsxedcqqqqazwsxedcqqqsxedcqqqwsxedcqqqedcqqqdcqqqedcqqqqqsxedcqqqwsxedcqqqedcqqqwsxedcqqqdcqqqdcqqqxedcqqqedcqqqwsxedcqqqsxedcqqqazwsxedcqqqsxedcqqqedcqqqwsxedcqqqazwsxedcqqqqqzwsxedcqqqqqazwsxedcqqqazwsxedcqqqwsxedcqqqzwsxedcqqqqqcqqqzwsxedcqqqwsxedcqqqqqqsxedcqqqsxedcqqqzwsxedcqqqdcqqqedcqqqsxedcqqqsxedcqqqwsxedcqqqqazwsxedcqqqdcqqqsxedcqqqwsxedcqqqqazwsxedcqqqcqqqqazwsxedcqqqwsxedcqqqsxedcqqqzwsxedcqqqedcqqqzwsxedcqqqazwsxedcqqqwsxedcqqqdcqqqazwsxedcqqqxedcqqqcqqqsxedcqqqzwsxedcqqqqazwsxedcqqqcqqqqqqazwsxedcqqqazwsxedcqqqazwsxedcqqqqazwsxedcqqqqqqqqcqqqdcqqqedcqqqxedcqqqqqwsxedcqqqwsxedcqqqzwsxedcqqqqqqsxedcqqqqazwsxedcqqqcqqqdcqqqzwsxedcqqqazwsxedcqqqqqcqqqqqqsxedcqqqcqqqqqqqwsxedcqqqdcqqqqqqazwsxedcqqqedcqqqazwsxedcqqqxedcqqqqqqqqxedcqqqcqqqzwsxedcqqqedcqqqdcqqqqqqwsxedcqqqxedcqqqcqqqcqqqdcqqqedcqqqedcqqqsxedcqqqxedcqqqazwsxedcqqqedcqqqxedcqqqqqwsxedcqqqsxedcqqqwsxedcqqqedcqqqdcqqqedcqqqedcqqqqqqqqqqxedcqqqdcqqqwsxedcqqqsxedcqqqwsxedcqqqqqdcqqqqqqcqqqzwsxedcqqqazwsxedcqqqazwsxedcqqqazwsxedcqqqedcqqqsxedcqqqdcqqqazwsxedcqqqwsxedcqqqqqcqqqzwsxedcqqqsxedcqqqsxedcqqqcqqqazwsxedcqqqqqqqwsxedcqqqxedcqqqqazwsxedcqqqedcqqqedcqqqqqqqzwsxedcqqqcqqqxedcqqqcqqqwsxedcqqqqazwsxedcqqqsxedcqqqwsxedcqqqqqzwsxedcqqqedcqqqsxedcqqqwsxedcqqqedcqqqcqqqqqedcqqqazwsxedcqqqedcqqqxedcqqqqqcqqqqqxedcqqqqazwsxedcqqqqazwsxedcqqqdcqqqazwsxedcqqqdcqqqqqqqqqdcqqqdcqqqsxedcqqqazwsxedcqqqdcqqqqqqazwsxedcqqqsxedcqqqqazwsxedcqqqcqqqwsxedcqqqedcqqqsxedcqqqqazwsxedcqqqwsxedcqqqedcqqqsxedcqqqazwsxedcqqqazwsxedcqqqwsxedcqqqcqqqwsxedcqqqqqqcqqqwsxedcqqqqazwsxedcqqqedcqqqqqqqazwsxedcqqqwsxedcqqqqqqqazwsxedcqqqxedcqqqqazwsxedcqqqcqqqedcqqqazwsxedcqqqqazwsxedcqqqdcqqqazwsxedcqqqzwsxedcqqqxedcqqqwsxedcqqqdcqqqsxedcqqqqazwsxedcqqqcqqqxedcqqqxedcqqqwsxedcqqqedcqqqxedcqqqqqazwsxedcqqqqqxedcqqqqqedcqqqdcqqqqqqdcqqqqqqqqqzwsxedcqqqdcqqqwsxedcqqqzwsxedcqqqdcqqqzwsxedcqqqqqqedcqqqqqqqsxedcqqqdcqqqwsxedcqqqazwsxedcqqqdcqqqsxedcqqqqqqqqwsxedcqqqqqqedcqqqxedcqqqxedcqqqwsxedcqqqcqqqazwsxedcqqqxedcqqqqazwsxedcqqqcqqqdcqqqedcqqqxedcqqqzwsxedcqqqedcqqqazwsxedcqqqazwsxedcqqqzwsxedcqqqxedcqqqwsxedcqqqdcqqqxedcqqqxedcqqqzwsxedcqqqwsxedcqqqazwsxedcqqq \ No newline at end of file diff --git "a/\346\233\276\351\235\222\345\207\244/open-write-close\344\275\234\344\270\232/work4.js" "b/\346\233\276\351\235\222\345\207\244/open-write-close\344\275\234\344\270\232/work4.js" new file mode 100644 index 0000000000000000000000000000000000000000..bcc7998e9ceb2a64de95a1c7b324b365d9530108 --- /dev/null +++ "b/\346\233\276\351\235\222\345\207\244/open-write-close\344\275\234\344\270\232/work4.js" @@ -0,0 +1,51 @@ +let fs = require("fs"); + +if (!fs.existsSync("bigdata"))fs.mkdirSync("bigdata"); + +let str = "azwsxedcqq"; +let startAt = new Date().getTime(); +let fd = fs.openSync("./bigdata/big.txt","a"); + +for (let i = 0; i < 100; i++) { + fs.writeSync(fd,str.slice(Math.floor(Math.random()*(str.length-1))),str.length-1); + +} + +fs.closeSync(fd); +let endAt = new Date().getTime(); +//console.log(endAt-startAt); + +let chatArray = []; +let readStream = fs.createReadStream("./bigdata/big.txt"); + +readStream.on("data",(chunk)=>{ + + let str = chunk.toString(); + for (let i = 0; i < str.length; i++) { + if (chatArray[str[i]]==undefined) { + chatArray[str[i]] = 1; + } else { + chatArray[str[i]] += 1; + } + + } +}); + +readStream.on("end",()=>{ + console.log(chatArray); + var max = 0; + var z = ''; + for (const key in chatArray) { + if(max < chatArray[key]){ + max = chatArray[key]; + z = key; + } + } + console.log("出现次数最多为:"+max); + console.log("出现次数最多的字符为:"+z); +}) + + + + +