From: Michael Koch Date: Tue, 2 Dec 2003 14:27:33 +0000 (+0000) Subject: Connection.java: Some reformating. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=84ebbc677783b09fd7031a6fb3ccfad89f0c3fc1;p=gcc.git Connection.java: Some reformating. 2003-12-02 Michael Koch * gnu/java/net/protocol/file/Connection.java: Some reformating. (file): Renamed from fileIn. (getPermission): Moved around. From-SVN: r74179 --- diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 789fa924b24..3e9b3d517d2 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,10 @@ +2003-12-02 Michael Koch + + * gnu/java/net/protocol/file/Connection.java: + Some reformating. + (file): Renamed from fileIn. + (getPermission): Moved around. + 2003-12-02 Michael Koch * gnu/java/net/protocol/jar/Connection.java diff --git a/libjava/gnu/java/net/protocol/file/Connection.java b/libjava/gnu/java/net/protocol/file/Connection.java index dddbd309482..fcae745e130 100644 --- a/libjava/gnu/java/net/protocol/file/Connection.java +++ b/libjava/gnu/java/net/protocol/file/Connection.java @@ -74,7 +74,7 @@ public class Connection extends URLConnection /** * This is a File object for this connection */ - private File fileIn; + private File file; /** * InputStream if we are reading from the file @@ -115,11 +115,12 @@ public class Connection extends URLConnection return; // If not connected, then file needs to be openned. - fileIn = new File(getURL().getFile()); + file = new File (getURL().getFile()); if (doInput) - inputStream = new BufferedInputStream(new FileInputStream(fileIn)); + inputStream = new BufferedInputStream(new FileInputStream(file)); + if (doOutput) - outputStream = new BufferedOutputStream(new FileOutputStream(fileIn)); + outputStream = new BufferedOutputStream(new FileOutputStream(file)); connected = true; } @@ -134,8 +135,9 @@ public class Connection extends URLConnection public InputStream getInputStream() throws IOException { - if (! doInput) + if (!doInput) throw new ProtocolException("Can't open InputStream if doInput is false"); + if (!connected) connect(); @@ -152,7 +154,7 @@ public class Connection extends URLConnection public OutputStream getOutputStream() throws IOException { - if (! doOutput) + if (!doOutput) throw new ProtocolException("Can't open OutputStream if doOutput is false"); @@ -163,6 +165,19 @@ public class Connection extends URLConnection } // Override default method in URLConnection. + /** + * This method returns a Permission object representing the + * permissions required to access this URL. This method returns a + * java.io.FilePermission for the file's path with a read + * permission. + * + * @return A Permission object + */ + public Permission getPermission() throws IOException + { + return permission; + } + public String getHeaderField(String name) { try @@ -176,7 +191,6 @@ public class Connection extends URLConnection return (String) hdrHash.get(name.toLowerCase()); } - // Override default method in URLConnection. public Map getHeaderFields() { try @@ -190,7 +204,6 @@ public class Connection extends URLConnection return hdrHash; } - // Override default method in URLConnection. public String getHeaderField(int n) { try @@ -207,7 +220,6 @@ public class Connection extends URLConnection return null; } - // Override default method in URLConnection. public String getHeaderFieldKey(int n) { try @@ -259,7 +271,7 @@ public class Connection extends URLConnection // to add others later and for consistency, we'll implement it this way. // Add the only header we know about right now: Content-length. - long len = fileIn.length(); + long len = file.length(); String line = "Content-length: " + len; hdrVec.addElement(line); @@ -269,18 +281,5 @@ public class Connection extends URLConnection String key = getKey(line); hdrHash.put(key.toLowerCase(), Long.toString(len)); } - - /** - * This method returns a Permission object representing the - * permissions required to access this URL. This method returns a - * java.io.FilePermission for the file's path with a read - * permission. - * - * @return A Permission object - */ - public Permission getPermission() throws IOException - { - return permission; - } } // class FileURLConnection