urlvfs.java

来自「Java写的文本编辑器」· Java 代码 · 共 92 行

JAVA
92
字号
/* * UrlVFS.java - Url VFS * Copyright (C) 2000 Slava Pestov * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. */package org.gjt.sp.jedit.io;import java.awt.Component;import java.io.*;import java.net.*;import org.gjt.sp.jedit.*;import org.gjt.sp.util.Log;/** * URL VFS. * @author Slava Pestov * @version $Id: UrlVFS.java,v 1.1.1.1 2001/09/02 05:38:17 spestov Exp $ */public class UrlVFS extends VFS{	public UrlVFS()	{		super("url");	}	public int getCapabilities()	{		return READ_CAP | WRITE_CAP;	}	public String constructPath(String parent, String path)	{		if(parent.endsWith("/"))			return parent + path;		else			return parent + '/' + path;	}	public String getParentOfPath(String path)	{		return MiscUtilities.getParentOfPath(path);	}	public InputStream _createInputStream(Object session,		String path, boolean ignoreErrors, Component comp)		throws IOException	{		try		{			return new URL(path).openStream();		}		catch(MalformedURLException mu)		{			Log.log(Log.ERROR,this,mu);			String[] args = { path, mu.getMessage() };			VFSManager.error(comp,"badurl",args);			return null;		}	}	public OutputStream _createOutputStream(Object session, String path,		Component comp) throws IOException	{		try		{			return new URL(path).openConnection()				.getOutputStream();		}		catch(MalformedURLException mu)		{			Log.log(Log.ERROR,this,mu);			String[] args = { path };			VFSManager.error(comp,"badurl",args);			return null;		}	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?