Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-17-2009, 07:58 AM
Member
 
Join Date: Nov 2008
Posts: 40
Rep Power: 0
Bomber_Will is on a distinguished road
Default Hosting an Applet on a website which reads a textfile
I wrote up a code of an Applet which needs to read in from a text file. I used this line to make the program read the text file:

BufferedReader input = new BufferedReader(new FileReader("test.txt"));

Now the code works fine in Eclipse and I have it so the .class and .java files are in the same folder. The test.txt file is also in the same folder with everything else. My problem is that when I try to host this Applet up, it doesn't read the text file at all. I put the html, class, java, and text files all in the public_html folder. How can I make the applet read from the text file while being hosted? Thanks
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 01-17-2009, 05:56 PM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 1,018
Rep Power: 3
Nicholas Jordan is on a distinguished road
Default
Put the text file on the server, not on the remote.
__________________
Introduction to Programming Using Java.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-17-2009, 07:42 PM
OrangeDog's Avatar
Senior Member
 
Join Date: Jan 2009
Location: Cambridge, UK
Posts: 838
Rep Power: 2
OrangeDog is on a distinguished road
Default
If the file is in the jar you can get it using ClassLoader.getResourceAsStream(). If it is on the server you can use URLConnection.getContent().

Last edited by OrangeDog; 01-17-2009 at 07:42 PM. Reason: clarify
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-17-2009, 07:48 PM
Member
 
Join Date: Nov 2008
Posts: 40
Rep Power: 0
Bomber_Will is on a distinguished road
Default
I did put it on the server

Edit: Would URLConnection.getContent() go inside the bufferedreader?

Edit: Nevermind I got it to work! Thank you so much.

Last edited by Bomber_Will; 01-17-2009 at 08:08 PM.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple example that reads a value from another class rizo New To Java 1 11-12-2008 04:43 PM
How to download website (Get all link in website) finalmem Advanced Java 0 11-12-2008 09:43 AM
The hosting company must have the frameworks? gilbertoalbino Web Frameworks 2 10-19-2008 04:51 AM
screen scraper for java applet website sheriek Java Applets 3 09-25-2008 10:48 AM
Is there any utility that reads TimeZone data and display it in Human readable format Santhosh Advanced Java 0 11-06-2007 03:20 PM


All times are GMT +2. The time now is 07:23 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org