Results 1 to 1 of 1
Thread: Opening a file
- 01-30-2011, 08:34 PM #1
Opening a file
I actually figured it out. here is the code neededI have a Jar file containing a class file called Loggin.class which is an applet, there is also another file called MREAManager.class
the MREAManager.class file loads a file outside of the Jar file called "lgindt.xls" the Loggin.class calls the MREAManager's constructor which then loads the File.
The file ("lgindt.xls") is at the same location as the Jar file. normally this would be ok and work, but it doesnt seem to find the file.
i created an HTML file to test the applet, the applet loads fine but doesnt load the file.
I heard i the URL class but i wasnt sure if that would work or not. if anyone has any ideas please share.
In the code above the URL is hard-wired into the constructor method for the URL class.URL url;
URLConnection urlConn;
InputStream dis;
url = new URL(dir);
urlConn = url.openConnection();
urlConn.setDoInput(true);
urlConn.setUseCaches(false);
dis = new DataInputStream(urlConn.getInputStream());
Next, create a URLConnection object named urlConnection by invoking url.openConnection(). Then, this connection is defined to be an input connection by invoking setDoInput() method of the URLConnection class. To make sure that we get a real copy of the data file and not a cached file, we also invoke setUsesCaches(false).Last edited by rdjava; 01-30-2011 at 09:31 PM.
Similar Threads
-
Help opening and reading a file
By viperlasson in forum New To JavaReplies: 0Last Post: 09-21-2010, 07:32 AM -
Opening mp3 file ( not reading )
By Char in forum New To JavaReplies: 15Last Post: 08-29-2010, 07:09 AM -
Opening .html file
By Prajin in forum New To JavaReplies: 7Last Post: 08-06-2010, 07:20 AM -
Error While Opening A PDF file
By Cluster Storm in forum AWT / SwingReplies: 6Last Post: 06-07-2010, 06:03 PM -
Problem in opening a file
By Raghav kv in forum New To JavaReplies: 1Last Post: 08-11-2007, 01:55 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks