aspose file tools*
The moose likes Applets and the fly likes can an applet read/write a file on the host instead of local system? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "can an applet read/write a file on the host instead of local system?" Watch "can an applet read/write a file on the host instead of local system?" New topic
Author

can an applet read/write a file on the host instead of local system?

Wenzhong Hu
Greenhorn

Joined: Jul 23, 2005
Posts: 1
Greeting,

My question is this: I need write an applet that have to access a file on the host server instead of local system. For example, if the applet is downloaded from www.xxx.com/lab4 , then that file also is in www.xxx.com/lab4. How can the applet connect back to its home directory to access that file?

Thanks a million!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42951
    
  72
Since the file is in the same directory as the applet, and thus publicly accessible, you can use the HttpURLConnection class to retrieve it.
[ July 24, 2005: Message edited by: Ulf Dittmer ]
Alan apz
Greenhorn

Joined: Aug 05, 2005
Posts: 9
lab4 rock
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

As Ulf says, reading the file is easy. To write to the file, you'll generally need a servlet or other server-side program to receive the data and write it to a file.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can an applet read/write a file on the host instead of local system?