当前位置: 首页>>代码示例>>PHP>>正文


PHP BufferedReader::read方法代码示例

本文整理汇总了PHP中BufferedReader::read方法的典型用法代码示例。如果您正苦于以下问题:PHP BufferedReader::read方法的具体用法?PHP BufferedReader::read怎么用?PHP BufferedReader::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BufferedReader的用法示例。


在下文中一共展示了BufferedReader::read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: read

 /**
  * Returns the next character in the filtered stream. If the desired
  * number of lines have already been read, the resulting stream is
  * effectively at an end. Otherwise, the next character from the
  * underlying stream is read and returned.
  *
  * @param int $len
  * @return int|string the next character in the resulting stream, or -1
  * if the end of the resulting stream has been reached
  *
  * @throws IOException if the underlying stream throws an IOException
  *                     during reading
  * @throws BuildException
  */
 public function read($len = 0)
 {
     // do the "singleton" initialization
     if (!$this->getInitialized()) {
         $this->initialize();
         $this->setInitialized(true);
     }
     $ch = -1;
     // The readers return -1 if they end. So simply read the "prepend"
     // after that the "content" and at the end the "append" file.
     if ($this->prependReader !== null) {
         $ch = $this->prependReader->read();
         if ($ch === -1) {
             // I am the only one so I have to close the reader
             $this->prependReader->close();
             $this->prependReader = null;
         }
     }
     if ($ch === -1) {
         $ch = parent::read();
     }
     if ($ch === -1 && $this->appendReader !== null) {
         $ch = $this->appendReader->read();
         if ($ch === -1) {
             // I am the only one so I have to close the reader
             $this->appendReader->close();
             $this->appendReader = null;
         }
     }
     return $ch;
 }
开发者ID:Ingewikkeld,项目名称:phing,代码行数:45,代码来源:ConcatFilter.php

示例2: setFile

 /**
  * set the text using a file
  * @param file the file to use
  * @throws BuildException if the file does not exist, or cannot be
  *                        read
  */
 public function setFile(PhingFile $file)
 {
     // non-existing files are not allowed
     if (!$file->exists()) {
         throw new BuildException("File " . $file . " does not exist.");
     }
     $reader = null;
     try {
         if ($this->encoding == null) {
             $reader = new BufferedReader(new FileReader($file));
         } else {
             $reader = new BufferedReader(new InputStreamReader(new FileInputStream($file)));
         }
         $this->value = $reader->read();
     } catch (IOException $ex) {
         $reader->close();
         throw new BuildException($ex);
     }
     $reader->close();
 }
开发者ID:kenguest,项目名称:phing,代码行数:26,代码来源:TextElement.php


注:本文中的BufferedReader::read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。