I have an applet that 1) reads an address from a textbox(on a user's screen) 2) matches the address against a simple .txt file on the applet's server. I've been trying to use RandomAccessFile("address.txt"), but I have been getting security errors... Please answer these questions for me: 1) True/False An applet has automatic access to any file in the directory from which it orginated (ie my website's server). 2) True/False You must use a URL object to connect the applet to its server.(in order to enable data transfer to the applet). 3) How do I tell the applet where the text file is (ie do i use "http://www.mywebsite.com/addresses"..) Any help plus hints and suggestions would be much appreciated. I am fairly new to java...
1. False. A web server isn't a file server. You can't just call open() on it, and what would you use for a drive ID, anyway? 2. No. You could always roll your own connection with sockets. 3. Because of 1, above, this isn't meaningful. What you'd actually do is place the file in one of the folders of the web server just like it was HTML. If it's a text file, your web server will normally serve it up (unless someone's changed the default configuration to something weird). You'll be able to see this by just typing in the URL for the text file, and watching it display in your browser. That's NOT a "file", however, it's a data stream loaded FROM the copy of the file on the server, and the semantic difference is important - there are HTTP headers and other things also coming down the pipe, and, as I've said, you can'd call your local open() function to make an HTTP request. In Java, the easiest way for an applet to retrieve the contents of a server-provided file is to create a URLConnection and open an input stream on it. What you do after that depends on what your app intends to do with the data.
"privilege" comes from the Latin words for "private" and "law" (legal) and dates to feudal times. To "claim privilege" meant that you were above the laws that applied to the common people.
Your buns are mine! But you can have this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!