Commit 1fa7e0fd by Michael Koch Committed by Michael Koch

2003-12-01 Michael Koch <konqueror@gmx.de>

	* gnu/java/net/protocol/file/Connection.java
	(fileIn): Documentation added.
	(inputStream): Likewise.
	(outputStream): Likewise.
	(Connection): Likewise.
	(connect): Simplified.

From-SVN: r74106
parent 3066a15c
2003-12-01 Michael Koch <konqueror@gmx.de>
* gnu/java/net/protocol/file/Connection.java
(fileIn): Documentation added.
(inputStream): Likewise.
(outputStream): Likewise.
(Connection): Likewise.
(connect): Simplified.
2003-12-01 Thomas Fitzsimmons <fitzsim@redhat.com> 2003-12-01 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkImage.java (setDimensions, * gnu/java/awt/peer/gtk/GtkImage.java (setDimensions,
......
...@@ -38,38 +38,71 @@ ...@@ -38,38 +38,71 @@
*/ */
package gnu.java.net.protocol.file; package gnu.java.net.protocol.file;
import java.net.URL;
import java.net.URLConnection;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.FilePermission;
import java.io.InputStream; import java.io.InputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.ProtocolException; import java.net.ProtocolException;
import java.net.URL;
import java.net.URLConnection;
import java.security.Permission;
import java.util.Map; import java.util.Map;
import java.util.Vector; import java.util.Vector;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Enumeration; import java.util.Enumeration;
/** /**
* This subclass of java.net.URLConnection models a URLConnection via
* the "file" protocol.
*
* @author Aaron M. Renn <arenn@urbanophile.com>
* @author Nic Ferrier <nferrier@tapsellferrier.co.uk>
* @author Warren Levy <warrenl@cygnus.com> * @author Warren Levy <warrenl@cygnus.com>
* @date April 13, 1999.
*/ */
public class Connection extends URLConnection public class Connection extends URLConnection
{ {
private Hashtable hdrHash = new Hashtable(); /**
private Vector hdrVec = new Vector(); * Default permission for a file
private boolean gotHeaders = false; */
private static final String DEFAULT_PERMISSION = "read";
/**
* This is a File object for this connection
*/
private File fileIn; private File fileIn;
/**
* InputStream if we are reading from the file
*/
private InputStream inputStream; private InputStream inputStream;
/**
* OutputStream if we are writing to the file
*/
private OutputStream outputStream; private OutputStream outputStream;
private Hashtable hdrHash = new Hashtable();
private Vector hdrVec = new Vector();
private boolean gotHeaders = false;
/**
* FilePermission to read the file
*/
private FilePermission permission;
/**
* Calls superclass constructor to initialize.
*/
public Connection(URL url) public Connection(URL url)
{ {
super (url); super (url);
permission = new FilePermission(getURL().getFile(), DEFAULT_PERMISSION);
} }
/** /**
...@@ -82,8 +115,7 @@ public class Connection extends URLConnection ...@@ -82,8 +115,7 @@ public class Connection extends URLConnection
return; return;
// If not connected, then file needs to be openned. // If not connected, then file needs to be openned.
String fname = url.getFile(); fileIn = new File(getURL().getFile());
fileIn = new File(fname);
if (doInput) if (doInput)
inputStream = new BufferedInputStream(new FileInputStream(fileIn)); inputStream = new BufferedInputStream(new FileInputStream(fileIn));
if (doOutput) if (doOutput)
...@@ -238,4 +270,17 @@ public class Connection extends URLConnection ...@@ -238,4 +270,17 @@ public class Connection extends URLConnection
hdrHash.put(key.toLowerCase(), Long.toString(len)); hdrHash.put(key.toLowerCase(), Long.toString(len));
} }
/**
* This method returns a <code>Permission</code> object representing the
* permissions required to access this URL. This method returns a
* <code>java.io.FilePermission</code> for the file's path with a read
* permission.
*
* @return A Permission object
*/
public Permission getPermission() throws IOException
{
return permission;
}
} // class FileURLConnection } // class FileURLConnection
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment