/**
* This is a File object for this connection
*/
- private File fileIn;
+ private File file;
/**
* InputStream if we are reading from the file
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;
}
public InputStream getInputStream()
throws IOException
{
- if (! doInput)
+ if (!doInput)
throw new ProtocolException("Can't open InputStream if doInput is false");
+
if (!connected)
connect();
public OutputStream getOutputStream()
throws IOException
{
- if (! doOutput)
+ if (!doOutput)
throw new
ProtocolException("Can't open OutputStream if doOutput is false");
}
// Override default method in URLConnection.
+ /**
+ * 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;
+ }
+
public String getHeaderField(String name)
{
try
return (String) hdrHash.get(name.toLowerCase());
}
- // Override default method in URLConnection.
public Map getHeaderFields()
{
try
return hdrHash;
}
- // Override default method in URLConnection.
public String getHeaderField(int n)
{
try
return null;
}
- // Override default method in URLConnection.
public String getHeaderFieldKey(int n)
{
try
// 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);
String key = getKey(line);
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