/** Release any resources held by the resource. */ public synchronized void release() { if (_in!=null) { try{_in.close();}catch(IOException e){Log.ignore(e);} _in=null; } if (_connection!=null) _connection=null; }
/** * closes an input stream, and logs exceptions * * @param is the input stream to close */ public static void close(InputStream is) { try { if (is != null) is.close(); } catch (IOException e) { Log.ignore(e); } }
/** * closes an output stream, and logs exceptions * * @param os the output stream to close */ public static void close(OutputStream os) { try { if (os != null) os.close(); } catch (IOException e) { Log.ignore(e); } }
protected synchronized boolean checkConnection() { if (_connection==null) { try{ _connection=_url.openConnection(); _connection.setUseCaches(_useCaches); } catch(IOException e) { Log.ignore(e); } } return _connection!=null; }
public static URL jarFor(String className) { try { className=className.replace('.','/')+".class"; // hack to discover jstl libraries URL url = Loader.getResource(null,className,false); String s=url.toString(); if (s.startsWith("jar:file:")) return new URL(s.substring(4,s.indexOf("!/"))); } catch(Exception e) { Log.ignore(e); } return null; } }
/** * Returns true if the represented resource exists. */ public boolean exists() { try { synchronized(this) { if (checkConnection() && _in==null ) _in = _connection.getInputStream(); } } catch (IOException e) { Log.ignore(e); } return _in!=null; }
protected boolean checkConnection() { super.checkConnection(); try { if (_jarConnection!=_connection) newConnection(); } catch(IOException e) { Log.ignore(e); _jarConnection=null; } return _jarConnection!=null; }
/** * Returns an File representing the given resource or NULL if this * is not possible. */ public File getFile() throws IOException { // Try the permission hack if (checkConnection()) { Permission perm = _connection.getPermission(); if (perm instanceof java.io.FilePermission) return new File(perm.getName()); } // Try the URL file arg try {return new File(_url.getFile());} catch(Exception e) {Log.ignore(e);} // Don't know the file return null; }
/** Release any resources held by the resource. */ public synchronized void release() { if (_in!=null) { try{_in.close();}catch(IOException e){Log.ignore(e);} _in=null; } if (_connection!=null) _connection=null; }
protected void doStop() throws Exception { super.doStop(); try {if (_writer != null) _writer.flush();} catch (IOException e) {Log.ignore(e);} if (_out != null && _closeOut) try {_out.close();} catch (IOException e) {Log.ignore(e);} _out = null; _fileOut = null; _closeOut = false; _logDateCache = null; _writer = null; }
protected void idleExpired() { try { close(); } catch (IOException e) { Log.ignore(e); } }
public InputStream getResourceAsStream(String path) { try { URL url=getResource(path); if (url==null) return null; return url.openStream(); } catch(Exception e) { Log.ignore(e); return null; } }
public void close() throws IOException { try { super.close(); } catch (IOException e) { Log.ignore(e); } finally { updateKey(); } }