public URLConnection openConnection(URL u) throws IOException { return new FileURL(u); } protected @Override synchronized InetAddress getHostAddress(URL u) {
public int getContentLength() { try { connect(); return (int) fo.getSize(); } catch (IOException ex) { return 0; } }
public void connect() throws IOException { if (fo != null) { return; } fo = decodeURL(url); if (fo == null) { throw new FileNotFoundException("Cannot find: " + url); // NOI18N } }
/** Find a good URL for this file object which works according to type: * <ul> * <li>inside this VM * <li>inside this machine * <li>from networked machines * </ul> * @return a suitable URL, or (only if not {@link #INTERNAL}) null */ public static URL findURL(FileObject fo, int type) { /** secondly registered URLMappers are asked to resolve URL */ for (URLMapper mapper : getInstances()) { URL retVal = mapper.getURL(fo, type); if (retVal != null) { return retVal; } } // if not resolved yet then internal URL with nbfs protocol is returned // XXX this would be better handled by making DefaultURLMapper just return nbfs for INTERNAL when necessary! if (type == INTERNAL) { return FileURL.encodeFileObject(fo); } return null; }
retVal = FileURL.encodeFileObject (fo); } catch (FileStateInvalidException iex) { return null;}
public @Override long getHeaderFieldDate(String name, long Default) { if (name.equalsIgnoreCase("last-modified")) { // NOI18N try { connect(); return fo.lastModified().getTime(); } catch (IOException e) { } } return super.getHeaderFieldDate(name, Default); }
public FileObject[] getFileObjects(URL url) { String prot = url.getProtocol(); if (prot.equals(FileURL.PROTOCOL)) { //// NOI18N FileObject retVal = FileURL.decodeURL(url); return (retVal == null) ? null : new FileObject[] { retVal }; } if (prot.equals("jar")) { //// NOI18N return getFileObjectsForJarProtocol(url); } if (prot.equals("file")) { //// NOI18N File f = toFile(url); if (f != null) { FileObject[] foRes = findFileObjectsInRepository(f); if ((foRes != null) && (foRes.length > 0)) { return foRes; } } } return null; }
/** * @param u - URL to open connection to. * @return new URLConnection. */ public URLConnection openConnection(URL u) throws IOException { return new FileURL (u); }
retVal = FileURL.encodeFileObject (fo); } catch (FileStateInvalidException iex) { return null;}
/** Get a header field (currently, content type only). * @param name the header name. Only <code>content-type</code> is guaranteed to be present. * @return the value (i.e., MIME type) */ public String getHeaderField(String name) { if (name.equalsIgnoreCase("content-type")) { // NOI18N try { connect(); if (fo.isFolder()) { return "text/html"; // NOI18N } else { return fo.getMIMEType(); } } catch (IOException e) { } } return super.getHeaderField(name); }
public void connect() throws IOException { if (fo != null) return; fo = decodeURL (url); if (fo == null) { throw new FileNotFoundException("Cannot find: " + url); // NOI18N } }
/** * @param u - URL to open connection to. * @return new URLConnection. */ public URLConnection openConnection(URL u) throws IOException { return new FileURL (u); }
public InputStream getInputStream() throws IOException, UnknownServiceException { connect(); if (iStream == null) { try { if (fo.isFolder()) { iStream = new FIS(fo); } else { iStream = fo.getInputStream(); } } catch (FileNotFoundException e) { ExternalUtil.exception(e); throw e; } } return iStream; }
public void connect() throws IOException { if (fo != null) return; fo = decodeURL (url); if (fo == null) { throw new FileNotFoundException("Cannot find: " + url); // NOI18N } }
public OutputStream getOutputStream() throws IOException, UnknownServiceException { connect(); if (fo.isFolder()) { throw new UnknownServiceException(); } if (oStream == null) { FileLock flock = fo.lock(); oStream = new LockOS(fo.getOutputStream(flock), flock); } return oStream; }
public FileObject[] getFileObjects(URL url) { String prot = url.getProtocol(); if (prot.equals("nbfs")) { //// NOI18N FileObject retVal = FileURL.decodeURL(url); return (retVal == null) ? null : new FileObject[] {retVal}; } if (prot.equals("jar")) { //// NOI18N return getFileObjectsForJarProtocol(url); } if (prot.equals("file")) { //// NOI18N File f = toFile(url); if (f != null) { FileObject[] foRes = findFileObjectsInRepository(f); if (foRes != null && foRes.length > 0) { return foRes; } } } return null; }
public int getContentLength() { try { connect(); return (int)fo.getSize(); } catch (IOException ex) { return 0; } }
public FileObject[] getFileObjects(URL url) { String prot = url.getProtocol(); if (prot.equals("nbfs")) { //// NOI18N FileObject retVal = FileURL.decodeURL(url); return (retVal == null) ? null : new FileObject[] {retVal}; } if (prot.equals("jar")) { //// NOI18N return getFileObjectsForJarProtocol(url); } if (prot.equals("file")) { //// NOI18N File f = toFile(url); if (f != null) { FileObject[] foRes = findFileObjectsInRepository(f); if (foRes != null && foRes.length > 0) { return foRes; } } } return null; }
public int getContentLength() { try { connect(); return (int)fo.getSize(); } catch (IOException ex) { return 0; } }
/** Get a header field (currently, content type only). * @param name the header name. Only <code>content-type</code> is guaranteed to be present. * @return the value (i.e., MIME type) */ public String getHeaderField(String name) { if (name.equalsIgnoreCase("content-type")) { // NOI18N try { connect(); if (fo.isFolder()) return "text/html"; // NOI18N else return fo.getMIMEType (); } catch (IOException e) { } } return super.getHeaderField(name); }