Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 278
  • Last Modified:

read zip file on Internet Server

hi,

i wrote an applet ,and here is the part of the code:

 { ZipInputStream zin = new ZipInputStream(new FileInputStream(zipname));
      ZipEntry entry;
     while ((entry = zin.getNextEntry()) != null)
     {
        if (entry.getName().equals(filename))
          {   BufferedReader in = new BufferedReader(new InputStreamReader(zin));
               do something.......
          }
it runs well in my computer, but when i upload it the server and run, it says: the file access denied. what the possible problem for this?

i just read file on server, not write or update, why denied?

very urgent. 50pst

ws1999
0
ws1999
Asked:
ws1999
  • 5
  • 4
  • 2
1 Solution
 
blackCommented:
it seems like you don't have read access, is this a unix system or a windows system?
in unix, sometimes the server runs under a certain account and the file has been copied their under another account name and the account the server uses does not have read access for that file.
0
 
objectsCommented:
Unsigned applets are not permitted to access the local disk (for reading or writing).
You need to sign your applet to permit access to local disk.
0
 
blackCommented:
please disregard my comment I didn't read the applet part
sorry!
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ws1999Author Commented:
hello objects

the zip file is not in local disk,but in the server.

0
 
objectsCommented:
The you'll need to use a different technique to open it. Remember that the applet is running on the client, so accessing files directly will access files on the client disk.

If the zip file is visible on the web server then you can use URLConnection to open it. Otherwise you'll need to use some cgi, or a servlet.
0
 
ws1999Author Commented:
hello object

would you please elabrate more in detail about the URL connection?

ws1999
0
 
objectsCommented:
The URLConnection class is used to make connections to URL's.

// Make a connection to a URL

URLConnection conn = new URLConnection(url);

// Get a stream for the connection

InputStream in = conn.getInputStream();

// Process data

ZipInputStream zin = new ZipInputStream(in);
...
0
 
ws1999Author Commented:
hello objects

this code seems wrong:

URLConnection conn = new URLConnection(url);

the compiler said the URLConnection is abstract and cannot be instaniciated.

so how can i access this object?

ws1999
0
 
objectsCommented:
Oops, typing too fast again, try:

URLConnection conn = url.openConnection();

sorry :)

In fact if you just want to read the data then you can actually just do:

InputStream in = url.openStream();
0
 
ws1999Author Commented:
thanks Objects, hope to give you more points future
0
 
objectsCommented:
Not a problem.
Thanks for the points :)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now