當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。