从流中读取文件内容，本方法不负责关闭流，请自行关闭
324122
public static String readFromInputStream(InputStream inputStream) {
        try {
            return IOUtils.toString(inputStream, Charset.forName("utf-8")).trim();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
1240717
function(file) {
            var me = this;

            // 移出invalid的文件
            $.each( me.request( 'get-files', Status.INVALID ), function() {
                me.request( 'remove-file', this );
            });

            // 如果指定了开始某个文件，则只开始指定的文件。
            if ( file ) {
                file = file.id ? file : me.request( 'get-file', file );

                if (file.getStatus() === Status.INTERRUPT) {
                    file.setStatus( Status.QUEUED );

                    $.each( me.pool, function( _, v ) {

                        // 之前暂停过。
                        if (v.file !== file) {
                            return;
                        }

                        v.transport && v.transport.send();
                        file.setStatus( Status.PROGRESS );
                    });

                    
                } else if (file.getStatus() !== Status.PROGRESS) {
                    file.setStatus( Status.QUEUED );
                }
            } else {
                $.each( me.request( 'get-files', [ Status.INITED ] ), function() {
                    this.setStatus( Status.QUEUED );
                });
            }

            if ( me.runing ) {
                me.owner.trigger('startUpload', file);// 开始上传或暂停恢复的，trigger event
                return Base.nextTick( me.__tick );
            }

            me.runing = true;
            var files = [];

            // 如果有暂停的，则续传
            file || $.each( me.pool, function( _, v ) {
                var file = v.file;

                if ( file.getStatus() === Status.INTERRUPT ) {
                    me._trigged = false;
                    files.push(file);

                    if (v.waiting) {
                        return;
                    }
                    
                    // 文件 prepare 完后，如果暂停了，这个时候只会把文件插入 pool, 而不会创建 tranport，
                    v.transport ? v.transport.send() : me._doSend(v);
                }
            });

            $.each(files, function() {
                this.setStatus( Status.PROGRESS );
            });

            file || $.each( me.request( 'get-files',
                    Status.INTERRUPT ), function() {
                this.setStatus( Status.PROGRESS );
            });

            me._trigged = false;
            Base.nextTick( me.__tick );
            me.owner.trigger('startUpload');
        }
557247
public static boolean encode(String contents, BarcodeFormat barcodeFormat, Integer margin,
			ErrorCorrectionLevel errorLevel, String format, int width, int height, String saveImgFilePath) {
		Boolean bool = false;
		BufferedImage bufImg;
		Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>();
		// 指定纠错等级
		hints.put(EncodeHintType.ERROR_CORRECTION, errorLevel);
		hints.put(EncodeHintType.MARGIN, margin);
		hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
		try {
			// contents = new String(contents.getBytes("UTF-8"), "ISO-8859-1");
			BitMatrix bitMatrix = new MultiFormatWriter().encode(contents, barcodeFormat, width, height, hints);
			MatrixToImageConfig config = new MatrixToImageConfig(0xFF000001, 0xFFFFFFFF);
			bufImg = MatrixToImageWriter.toBufferedImage(bitMatrix, config);
			bool = writeToFile(bufImg, format, saveImgFilePath);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return bool;
	}
892918
function cleanContent(content) {
    if (!clean) {
      return content;
    }
    return String(content).replace(/^[^\n\S]*$/gm, '') // 清除空行
      .replace(/\n{2,}/gm, '\n'); // 清除连接的空行
  }
1038945
function () {
    var chunks = [];
    return through2.obj(function (file, enc, cb) {
        chunks.push(file);
        var string = file._contents.toString();
        var regex  = /\/\*\*debug:start\*\*\/[\s\S]*\/\*\*debug:end\*\*\//g;
        var stripped = string.replace(regex, "");
        file.contents = new Buffer(stripped);
        this.push(file);
        cb();
    });
}
728240
function runFile(src, context) {

    // 格式作路径
    src = path.cwd(src);

    // 返回运行结果
    return runCode(fs.readFileSync(src, 'utf8'), {
        __dirname: path.dirname(src),
        __filename: src,
        ...context
    });
}
1074728
function () {
        var fileList = [];
        /*获取原文件列表*/
        Object.keys(src).forEach(function(key){
            fileList.push(src[key]);
        });
        return fileList;
    }
1118520
function saveByFilesPath(readFilesPath, saveFilesPath, program, showLogs) {
  if (!readFilesPath || !saveFilesPath || !program) {
    console.error(chalk.red('参数缺漏！'));
    process.exit(1);
    return;
  }
  let { i18n, breadcrumb, all } = program;
  readFilesPath.forEach((v, k) => {
    //兼容windwos平台路径
    v = v.replace(/\\/g, '/');
    var contents = fs.readFileSync(v, {
      encoding: 'utf-8',
    });
    if (this.pageName) {
      //处理viem template 中的替换，根据this.pageName来判断
      contents = contents.replace(/\${pageName}/g, this.pageName);
      var pageNameSplit = this.pageName.split('-');
      pageNameSplit = pageNameSplit.map(v => {
        v = util.toUpperCaseByPosition(v, 0, 1);
        return v;
      });
      var pageNameCombine = pageNameSplit.join('');
      contents = contents.replace(
        /\${pageNameFirstLetter}/g,
        util.toUpperCaseByPosition(pageNameCombine, 0, 1)
      );
    }
    if (all) {
      //启用全部特性功能
      contents = this.removeTag(contents, '.*');
    } else {
      if (i18n) {
        //启用i18n功能
        contents = this.removeTag(contents, 'Locale');
      } else {
        //移除this.t(xxx)，不移除会报错
        var m = contents.match(/\.t\(["'](.*)["']\)/g);
        m &&
          m.forEach(v2 => {
            var t = v2.split('"');
            if (!t[1]) {
              t = v2.split("'");
            }
            contents = contents.replace(`this.t('${t[1]}')`, `'${t[1]}'`);
            contents = contents.replace(`this.t("${t[1]}")`, `'${t[1]}'`);
            contents = contents.replace(
              new RegExp(`{.*'${t[1]}'.*}`, 'g'),
              t[1]
            );
          });
      }
      if (breadcrumb) {
        //启用面包屑功能
        contents = this.removeTag(contents, 'BreadCrumb');
      }
    }
    //统一移除自定义tag（//≤--begin），包括tag内容
    contents = this.removeTagContents(contents, '.*');
    var filePahtSplit = v.split('/');
    var fileName = filePahtSplit[filePahtSplit.length - 1];
    var savePath = path.resolve(saveFilesPath[k]);
    fs.ensureFileSync(savePath);
    fs.writeFileSync(savePath, contents, {
      mode: 0o777,
    });
    if (showLogs) {
      console.log(chalk.green(fileName + ' is saved at:'));
      console.log(chalk.cyan(savePath));
    }
  });
}
1316077
def call(path, *args, encoding="utf-8", show_command=False):
    
    returncode = 0
    output = None
    try:
        # 2015-10-10 zrong
        # 在 windows 上使用 universal_newlines=True
        # 会导致输出信息为中文时出现编码错误
        # 原因是 check_out 中读入 stdout 内容的 read 方法没有传递编码参数
        # 因此不再使用 universal_newlines=True 这个参数
        # 而改用直接返回 bytes，然后对其解码
        arg_list = get_args(path, *args)
        if show_command:
            print('git call args:', arg_list)
        output = subprocess.check_output(arg_list, 
                stderr=subprocess.STDOUT)
        output = output.decode(encoding=encoding)
    except subprocess.CalledProcessError as err:
        returncode = err.returncode
        output = err.output.decode(encoding=encoding)
    return returncode, output
482333
private static void analyzeCorpus(String zipFile, String output, final String separator, final boolean includePhrase) throws IOException{
        File outputFile = new File(output);
        //准备输出目录
        if(!outputFile.getParentFile().exists()){
            outputFile.getParentFile().mkdirs();
        }
        try (FileSystem fs = FileSystems.newFileSystem(Paths.get(zipFile), ExtractText.class.getClassLoader());
                BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile),"utf-8"));) {
            for(Path path : fs.getRootDirectories()){                
                LOGGER.info("处理目录："+path);
                Files.walkFileTree(path, new SimpleFileVisitor<Path>(){

                    @Override
                    public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                        LOGGER.info("处理文件："+file);
                        // 拷贝到本地文件系统
                        Path temp = Paths.get("target/corpus-"+System.currentTimeMillis()+".txt");
                        Files.copy(file, temp, StandardCopyOption.REPLACE_EXISTING);
                        extractText(temp, writer, separator, includePhrase);
                        return FileVisitResult.CONTINUE;
                    }
                    
                });
            }
        }
    }
1290658
function getNewContent(content, imgRelativePath) {
  // 获得body中的内容
  content = content.match(/<body>((.|\r|\n)*)<\/body>/)[1];

  // 获得文章的内容，注意将<br/>替换为\r\n，将 &gt; 转义为 > ，将 &lt; 转义为 <
  content = content.replace(/<br\/>/g, '\r\n').replace(/&gt;/g, '>').replace(/&lt;/g, '<');

  // 删除img图片
  content = content.replace(/<div.*name="markdownimage"[^>]*>.*<\/div>/g, '');

  // 修改md中的相对图片
  content = content.replace(/\((index_files)[^\)]*\)/g, function (world, p1) {
    return world.replace(p1, imgRelativePath.replace(/\\/g, '/'));
  });

  return content;
}
1304168
public function read()
    {
        $args = array_merge(
            [$this->filename],
            [false, null],
            func_get_args()
        );

        return file_get_contents(...$args);
    }
564042
function parseContent(options, contents, filePath, asyncMod, callback) {
    // 读取主入口路径信息
    // eg: {id: "a", path: "/Users/tankunpeng/WebSite/gulp-seajs-combo/test/src/a.js", extName: ".js"}
    var pathResult = modPathResolve(options, filePath);
    // 设置入口模块基于base的真实id
    pathResult.origId = getorigIdbyBase(options, filePath, true);
    if (asyncMod) pathResult.asyncMod = asyncMod;
    // 读取主入口依赖模块路径信息
    // [{id: "b", extName: "", path: "/Users/tankunpeng/WebSite/gulp-seajs-combo/test/src/b", origId: "./b"},...]
    var deps = parseDeps(options, contents, pathResult);
    if (deps.length) {
        readDeps(options, deps);
        callback && callback();
    } else {
        callback && callback();
    }
}
909187
public void tagFile(String input,String output,String sep){
		String s = tagFile(input,"\n");
		try {
			OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(
					output), "utf-8");
			BufferedWriter bw = new BufferedWriter(writer);
			bw.write(s);
			bw.close();
		} catch (Exception e) {
			System.out.println("写输出文件错误");
			e.printStackTrace();
		}
	}
364977
private void readTail() throws IOException {
		final long len = this.randomAccessFile.length();

		if (initReadLine > 0) {
			long start = this.randomAccessFile.getFilePointer();
			long nextEnd = len - 1;
			this.randomAccessFile.seek(nextEnd);
			int c;
			int currentLine = 0;
			while (nextEnd > start) {
				// 满
				if (currentLine > initReadLine) {
					break;
				}
				c = this.randomAccessFile.read();
				if (c == CharUtil.LF || c == CharUtil.CR) {
					FileUtil.readLine(this.randomAccessFile, this.charset, this.lineHandler);
					currentLine++;
					nextEnd--;
				}
				nextEnd--;
				this.randomAccessFile.seek(nextEnd);
				if (nextEnd == 0) {
					// 当文件指针退至文件开始处，输出第一行
					FileUtil.readLine(this.randomAccessFile, this.charset, this.lineHandler);
					break;
				}
			}
		}

		// 将指针置于末尾
		try {
			this.randomAccessFile.seek(len);
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
	}
462259
public function parse(&$content)
    {
        // 内容为空不解析
        if (empty($content)) {
            return;
        }

        // 替换literal标签内容
        $this->parseLiteral($content);

        // 解析继承
        $this->parseExtend($content);

        // 解析布局
        $this->parseLayout($content);

        // 检查include语法
        $this->parseInclude($content);

        // 替换包含文件中literal标签内容
        $this->parseLiteral($content);

        // 检查PHP语法
        $this->parsePhp($content);

        // 获取需要引入的标签库列表
        // 标签库只需要定义一次，允许引入多个一次
        // 一般放在文件的最前面
        // 格式：<taglib name="html,mytag..." />
        // 当TAGLIB_LOAD配置为true时才会进行检测
        if ($this->config['taglib_load']) {
            $tagLibs = $this->getIncludeTagLib($content);

            if (!empty($tagLibs)) {
                // 对导入的TagLib进行解析
                foreach ($tagLibs as $tagLibName) {
                    $this->parseTagLib($tagLibName, $content);
                }
            }
        }

        // 预先加载的标签库 无需在每个模板中使用taglib标签加载 但必须使用标签库XML前缀
        if ($this->config['taglib_pre_load']) {
            $tagLibs = explode(',', $this->config['taglib_pre_load']);

            foreach ($tagLibs as $tag) {
                $this->parseTagLib($tag, $content);
            }
        }

        // 内置标签库 无需使用taglib标签导入就可以使用 并且不需使用标签库XML前缀
        $tagLibs = explode(',', $this->config['taglib_build_in']);

        foreach ($tagLibs as $tag) {
            $this->parseTagLib($tag, $content, true);
        }

        // 解析普通模板标签 {$tagName}
        $this->parseTag($content);

        // 还原被替换的Literal标签
        $this->parseLiteral($content, true);

        return;
    }
817205
function watchOnFile(file, callback) {
  let lastIndex = 0
  let timer

  function read() {
    const stat = fs.statSync(file)

    if (stat.size !== lastIndex) {
      const fd = fs.openSync(file, 'r')
      const buffer = Buffer.alloc(stat.size - lastIndex)

      try {
        fs.readSync(fd, buffer, lastIndex, stat.size - lastIndex)
        const content = buffer.toString('utf8')
        lastIndex = stat.size

        callback(content)
      } catch (error) {
        // 从头读起
        lastIndex = 0
      }
    }

    timer = setTimeout(read, 200)
  }

  read()
  return function() {
    clearTimeout(timer)
  }
}