1 21 22 package org.apache.derby.impl.io; 23 24 import org.apache.derby.io.StorageFile; 25 import org.apache.derby.io.StorageRandomAccessFile; 26 27 import org.apache.derby.iapi.services.sanity.SanityManager; 28 29 import java.io.InputStream ; 30 import java.io.OutputStream ; 31 import java.io.IOException ; 32 import java.io.FileNotFoundException ; 33 34 import java.net.URL ; 35 36 40 class URLFile extends InputStreamFile 41 { 42 43 private final URLStorageFactory storageFactory; 44 45 URLFile( URLStorageFactory storageFactory, String path) 46 { 47 super( storageFactory, path); 48 this.storageFactory = storageFactory; 49 } 50 51 URLFile( URLStorageFactory storageFactory, String parent, String name) 52 { 53 super( storageFactory, parent, name); 54 this.storageFactory = storageFactory; 55 } 56 57 URLFile( URLFile dir, String name) 58 { 59 super( dir,name); 60 this.storageFactory = dir.storageFactory; 61 } 62 63 private URLFile( URLStorageFactory storageFactory, String child, int pathLen) 64 { 65 super( storageFactory, child, pathLen); 66 this.storageFactory = storageFactory; 67 } 68 69 74 public boolean exists() 75 { 76 try 77 { 78 InputStream is = getInputStream(); 79 if( is == null) 80 return false; 81 is.close(); 82 return true; 83 } 84 catch( IOException ioe){ return false;} 85 } 87 92 StorageFile getParentDir( int pathLen) 93 { 94 return new URLFile( storageFactory, path, pathLen); 95 } 96 97 104 public InputStream getInputStream( ) throws FileNotFoundException 105 { 106 try 107 { 108 URL url = new URL ( path); 109 return url.openStream(); 110 } 111 catch( IOException ioe){ throw new java.io.FileNotFoundException (path);} 112 } } 114 | Popular Tags |