[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/imagex/postlet/rev_unkn/ -> ReadLine.java (source)

   1  /*    Copyright (C) 2006 Simon David Rycroft
   2  
   3      This program is free software; you can redistribute it and/or
   4      modify it under the terms of the GNU General Public License
   5      as published by the Free Software Foundation; either version 2
   6      of the License, or (at your option) any later version.
   7  
   8      This program is distributed in the hope that it will be useful,
   9      but WITHOUT ANY WARRANTY; without even the implied warranty of
  10      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11      GNU General Public License for more details.
  12  
  13      You should have received a copy of the GNU General Public License
  14      along with this program; if not, write to the Free Software
  15      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
  16  
  17  import java.io.BufferedReader;
  18  import java.io.IOException;
  19  
  20  public class ReadLine extends Thread {
  21  
  22      BufferedReader input;
  23      String read;
  24      private static final String newLine = "\n";
  25      UploadThread parent;
  26  
  27      public ReadLine (BufferedReader i, UploadThread p){
  28  
  29          parent = p;
  30          input = i;
  31          read = "";
  32      }
  33  
  34      public synchronized void run(){
  35  
  36          try {
  37              String line="";
  38              while ((line = input.readLine())!=null){
  39                  this.read += line + newLine;
  40                  if (line.equals("")){
  41                      try {
  42                          parent.notify();
  43                      }
  44                      catch (IllegalMonitorStateException ime){
  45                          // It appears the thread didn't need notifying
  46                          // so, lets not worry about it (Timed out).
  47                      }
  48                  }
  49              }
  50          }
  51          catch (IOException ioe){
  52              // Likely as a result of the socket being closed.
  53              // Notify parent (may be waiting).
  54              try {
  55                  parent.notify();
  56              }
  57              catch (IllegalMonitorStateException ime){
  58                  // It appears the thread didn't need notifying
  59                  // so, lets not worry about it (Timed out).
  60              }
  61          }
  62      }
  63  
  64      public String getRead(){
  65  
  66          return this.read;
  67      }
  68  }


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7