From a4a0ae650b1d0c705f97b6d3c990cabe1a6a90b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=BE=E9=9D=92=E5=87=A4?= <2658978250@qq.com> Date: Thu, 23 Feb 2023 09:29:13 +0000 Subject: [PATCH] =?UTF-8?q?open-write-close=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 曾青凤 <2658978250@qq.com> --- .../bigdata/big.txt" | 1 + .../work4.js" | 51 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 "\346\233\276\351\235\222\345\207\244/open-write-close\344\275\234\344\270\232/bigdata/big.txt" create mode 100644 "\346\233\276\351\235\222\345\207\244/open-write-close\344\275\234\344\270\232/work4.js" 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 0000000..03567b1 --- /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 0000000..bcc7998 --- /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); +}) + + + + + -- Gitee