Ignore:
Timestamp:
2003-11-24T14:26:35+13:00 (20 years ago)
Author:
cs025
Message:

Index document type, metadata extensions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/DocumentLoader.java

    r5800 r5944  
    66public class DocumentLoader
    77{
    8     public static String getAsString(InputStream in)
    9     {   StringBuffer reply;
    10         byte    data[] = new byte[128];
    11         int     databytes;
     8  public static String getAsString(InputStream in)
     9  { StringBuffer reply;
     10    byte    data[] = new byte[1024];
     11    int     databytes;
    1212
    13         reply   = new StringBuffer();
     13    reply   = new StringBuffer();
     14   
     15    try
     16    {
     17      do
     18      { databytes = in.read(data);
     19        if (databytes > 0)
     20    { reply.append(new String(data, 0, databytes));
     21    }
     22      } while (databytes >= 0);
     23    }
     24    catch (IOException io)
     25    {
     26    }
     27   
     28    return reply.toString();
     29  }
    1430
    15         try
    16         {
    17             do
    18             { databytes = in.read(data);
    19                 if (databytes > 0)
    20                 {   reply.append(new String(data, 0, databytes));
    21                 }
    22             } while (databytes >= 0);
    23         }
    24         catch (IOException io)
    25         {
    26         }
     31  public static String getAsString(File file)
     32  { FileInputStream in;
     33    String          reply = null;
    2734
    28         return reply.toString();
     35    try
     36    { in    = new FileInputStream(file);
     37      if (in == null)
     38    {   return null;
    2939    }
     40      reply = getAsString(in);
     41     
     42      in.close();
     43    }
     44    catch (IOException io)
     45    { return null;
     46    }
     47    return reply;
     48  }
    3049
    31     public static String getAsString(File file)
    32     { FileInputStream in;
    33         String                  reply = null;
    34 
    35         try
    36         {   in  = new FileInputStream(file);
    37             if (in == null)
    38             {   return null;
    39             }
    40             reply = getAsString(in);
    41 
    42             in.close();
    43         }
    44         catch (IOException io)
    45         {   return null;
    46         }
    47         return reply;
    48     }
    49 
    50     public static String getAsString(URL url)
    51     {   if (url.toString().startsWith("file://"))
    52         {   File file = new File(url.toString().substring(7));
    53             return getAsString(file);
    54         }
    55         return null;
    56     }
     50  public static String getAsString(URL url)
     51  { if (url.toString().startsWith("file://"))
     52    { File file = new File(url.toString().substring(7));
     53      return getAsString(file);
     54    }
     55    else if (url.toString().startsWith("file:/"))
     56    { File file = new File(url.toString().substring(5));
     57      return getAsString(file);
     58    }
     59 
     60    return null;
     61  }
    5762}
Note: See TracChangeset for help on using the changeset viewer.