Thread: BufferedWriter?

Results 1 to 6 of 6
  1. #1 BufferedWriter? 
    Registered Member
    Core's Avatar
    Join Date
    Sep 2007
    Posts
    4,194
    Thanks given
    11
    Thanks received
    393
    Rep Power
    1985
    Well Marshal told me I should make my pk point high scores read from a file, and I am not really sure how to convert this in to taking it from the file instead of righting in the file itself.
    Code:
    bw = new BufferedWriter(new FileWriter("Pk Highscores.java", true));
    and then would I make it liek this?
    Code:
    sendQuest(bw.write(server.rankPpl[i]+": "+server.ranks[i]), 8147);
    or something like that, I kinda just wrote that out.
     

  2. #2  
    Registered Member
    Shamon King's Avatar
    Join Date
    Aug 2007
    Posts
    3,336
    Thanks given
    90
    Thanks received
    228
    Rep Power
    1363
    use the bufferedReader to read it from a file and use the bufferedWritter to write it
     

  3. #3  
    Registered Member
    Core's Avatar
    Join Date
    Sep 2007
    Posts
    4,194
    Thanks given
    11
    Thanks received
    393
    Rep Power
    1985
    Thanks not so good with reading and writing from other file stuff.


    I still need help with this part...
    how would I make it say it on the highscores?

    Code:
    sendQuest(br.write(server.rankPpl[i]+": Pk Points - "+server.ranks[i]), 8147);
    I'm kinda lost I have never done this before.
     

  4. #4  
    pljay03
    Guest
    Shamon_King is right, "BufferedWriter" is used to write to files whereas "BufferedReader" reads from a file. Here's a little method I made for my own server, use it as an outline:

    Code:
    	public void loadMenu(String menu) // by narco: [email protected]
    	{
    		String toRead;
    		int line = 8147;
    		sendFrame126("@[email protected]" + capitalize(menu) + " Menu", 8144); //Helpmenu title
    		clearQuestInterface();
    		sendFrame126("", 8145);
    		
    		try
    		{
    			BufferedReader io = new BufferedReader(new FileReader(server.configLoc + "menus\\" + menu.toLowerCase().replaceAll(" ", "_") + ".log"));
    					
    			while((toRead = io.readLine()) != null)
    			{
    				toRead = toRead.replaceAll(":playerName:", capitalize(playerName));
    				
    				sendFrame126(toRead, line);
    				line++;
    			}
    			
    			io.close();
    		}
    		catch(Exception e)
    		{
    			println_debug("<method:client.load_menu>Exception -> " + e);
    		}
    		
    		sendQuestSomething(8143);
    		showInterface(8134);
    	}
    Hope this helps

    EDIT: thanks Shamon
     

  5. #5  
    Registered Member
    Shamon King's Avatar
    Join Date
    Aug 2007
    Posts
    3,336
    Thanks given
    90
    Thanks received
    228
    Rep Power
    1363
    im-not-alive you should close your buffers
     

  6. #6  
    pljay03
    Guest
    Quote Originally Posted by shamon king View Post
    im-not-alive you should close your buffers
    Lol, I'm humbled ^_^ Thanks for reminding me mate.
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

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