User: vharcq  
  Date: 02/03/14 12:29:28

  Modified:    core/src/xdoclet/util FileManager.java
  Log:
  Avoid to hang if the file has nothing in it
  
  Revision  Changes    Path
  1.6       +11 -4     xdoclet/core/src/xdoclet/util/FileManager.java
  
  Index: FileManager.java
  ===================================================================
  RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/util/FileManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -w -r1.5 -r1.6
  --- FileManager.java  15 Feb 2002 17:57:51 -0000      1.5
  +++ FileManager.java  14 Mar 2002 20:29:28 -0000      1.6
  @@ -7,6 +7,7 @@
   import java.util.HashMap;
   import java.util.Map;
   import xdoclet.XDocletException;
  +import org.apache.log4j.Category;
   
   /**
    * A utility class for handling common filing operations. It also caches loaded
  @@ -14,7 +15,7 @@
    *
    * @author    Ara Abrahamian ([EMAIL PROTECTED])
    * @created   Aug 5, 2001
  - * @version   $Revision: 1.5 $
  + * @version   $Revision: 1.6 $
    * @todo      Deal with Translator.getString()'s exception better (throw it so
    *      the build stops?) in getFileContent(String)
    */
  @@ -34,18 +35,24 @@
                try
                {
                        java.io.InputStream is = null;
  -                     if( "file".equals( url.getProtocol() ) ) {
  +
  +                     if( "file".equals( url.getProtocol() ) )
  +                     {
                                is = new java.io.FileInputStream( url.getFile() );
  -                     } else {
  +                     }
  +                     else
  +                     {
                                is = url.openStream();
                        }
  +
                        java.io.InputStream in = new BufferedInputStream( is );
   
                        ByteArrayOutputStream baos = new ByteArrayOutputStream( 
in.available() );
  +
                        byte[] b = new byte[in.available()];
                        int len;
   
  -                     while( ( len = in.read( b ) ) != -1 )
  +                     while( in.available() > 0 && ( len = in.read( b ) ) != -1 )
                        {
                                baos.write( b, 0, len );
                        }
  
  
  

_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to