Results 1 to 4 of 4
  1. #1
    Bomber_Will is offline Member
    Join Date
    Nov 2008
    Posts
    40
    Rep Power
    0

    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

  2. #2
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    7

    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

  3. #3
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    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 06:42 PM. Reason: clarify

  4. #4
    Bomber_Will is offline Member
    Join Date
    Nov 2008
    Posts
    40
    Rep Power
    0

    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 07:08 PM.

Similar Threads

  1. Replies: 1
    Last Post: 11-12-2008, 03:43 PM
  2. How to download website (Get all link in website)
    By finalmem in forum Advanced Java
    Replies: 0
    Last Post: 11-12-2008, 08:43 AM
  3. The hosting company must have the frameworks?
    By gilbertoalbino in forum Web Frameworks
    Replies: 2
    Last Post: 10-19-2008, 03:51 AM
  4. screen scraper for java applet website
    By sheriek in forum Java Applets
    Replies: 3
    Last Post: 09-25-2008, 09:48 AM
  5. Replies: 0
    Last Post: 11-06-2007, 02:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •