1 22 23 package org.gjt.sp.jedit.io; 24 25 import java.awt.Component ; 27 import java.io.*; 28 import java.net.*; 29 import org.gjt.sp.util.Log; 30 32 37 public class UrlVFS extends VFS 38 { 39 public UrlVFS() 41 { 42 super("url",READ_CAP | WRITE_CAP); 43 } 45 public String constructPath(String parent, String path) 47 { 48 if(parent.endsWith("/")) 49 return parent + path; 50 else 51 return parent + '/' + path; 52 } 54 public InputStream _createInputStream(Object session, 56 String path, boolean ignoreErrors, Component comp) 57 throws IOException 58 { 59 try 60 { 61 return new URL(path).openStream(); 62 } 63 catch(MalformedURLException mu) 64 { 65 Log.log(Log.ERROR,this,mu); 66 String [] args = { mu.getMessage() }; 67 VFSManager.error(comp,path,"ioerror.badurl",args); 68 return null; 69 } 70 } 72 public OutputStream _createOutputStream(Object session, String path, 74 Component comp) throws IOException 75 { 76 try 77 { 78 return new URL(path).openConnection() 79 .getOutputStream(); 80 } 81 catch(MalformedURLException mu) 82 { 83 Log.log(Log.ERROR,this,mu); 84 String [] args = { mu.getMessage() }; 85 VFSManager.error(comp,path,"ioerror.badurl",args); 86 return null; 87 } 88 } } 90 | Popular Tags |