Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-23-2012, 08:14 PM   PM User | #1
MBtask
New to the CF scene

 
Join Date: Jun 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
MBtask is an unknown quantity at this point
Question about reading files in JApplet

I don't think it is an issue with my code so I will just explain the situation and hopefully it can be cleared up. I have a JApplet that is reading a .txt file with the names of all the players. When I create a player this file is updated to add the player to the list using php, this works fine and I can read the player list from the text file when I load the applet and if I create a character the php file updates my text file instantly. If I try to read the list of players from the text file again using my same method that read it fine on start up it doesn't read the updated file.
So basically I am wondering if the applet is just preloading all the files when it starts instead of directly reading them from the server each time. If this is the case is there a way to get it to update the files.

Here is how I am reading the file. It works fine but just doesn't recognize a change to the file while the applet is loaded.

Code:
try{
         URL url = new URL("http://mywebsitegoeshere.com/playerNames.txt");
      
         BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
      
         String line = "";
      
         while(null != (line = br.readLine())) {
            if(line.equals(name + ".txt")){
               return true;
            }
         }
         br.close();
         
         
      }catch(Exception er){

      }
That is just a piece of the method it is just comparing the name they are trying to login as with the list if characters created which are also .txt files. I decided to do it like this because I figured it would be easy for a simple saving of character info and high scores but obviously not secure since anyone could call my php scripts from outside the applet.
MBtask is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 04:25 PM.


Advertisement
Log in to turn off these ads.