- Timestamp:
- 2003-11-24T14:26:35+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/DocumentLoader.java
r5800 r5944 6 6 public class DocumentLoader 7 7 { 8 9 {StringBuffer reply;10 byte data[] = new byte[128];11 8 public static String getAsString(InputStream in) 9 { StringBuffer reply; 10 byte data[] = new byte[1024]; 11 int databytes; 12 12 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 } 14 30 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; 27 34 28 return reply.toString(); 35 try 36 { in = new FileInputStream(file); 37 if (in == null) 38 { return null; 29 39 } 40 reply = getAsString(in); 41 42 in.close(); 43 } 44 catch (IOException io) 45 { return null; 46 } 47 return reply; 48 } 30 49 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 } 57 62 }
Note:
See TracChangeset
for help on using the changeset viewer.