Thread: bufferedwriter wont write.

Results 1 to 9 of 9
  1. #1 bufferedwriter wont write. 
    Banned

    Join Date
    Jul 2008
    Age
    28
    Posts
    5,827
    Thanks given
    1,301
    Thanks received
    197
    Rep Power
    0
    why dosent this work?

    Code:
    		public void writeToFile(String str, String file) {
    			try {
    				BufferedWriter bw = null;
    				bw = new BufferedWriter(new FileWriter(file));
    				bw.write(str);
    			} catch(Exception exx) {
    				System.out.println("could not write");}
    		}
    it just dosent write anything to the file. no exception or anything.
    Reply With Quote  
     

  2. #2  
    Registered Member

    Join Date
    Sep 2007
    Age
    32
    Posts
    2,396
    Thanks given
    5
    Thanks received
    436
    Rep Power
    902
    theres more to the method than that but not much more
    Hyperion V2 Martin's Updates.

    Scar says:
    i hate it when it hits your face
    Reply With Quote  
     

  3. #3  
    Banned

    Join Date
    Jul 2008
    Age
    28
    Posts
    5,827
    Thanks given
    1,301
    Thanks received
    197
    Rep Power
    0
    whats missing..?
    Reply With Quote  
     

  4. #4  
    Registered Member

    Join Date
    Jan 2009
    Posts
    274
    Thanks given
    0
    Thanks received
    2
    Rep Power
    97
    Cores Ban Command Log Method
    Code:
    		public void writeLog(String data, String file) {
    		BufferedWriter bw = null;
    			try {
    				bw = new BufferedWriter(new FileWriter("bin/data/" + file + ".txt",true));
    				bw.write(data);
    				bw.newLine();
    				bw.flush();
    			} catch (IOException ioe) {
    				ioe.printStackTrace();
    			} finally {
    				if (bw != null)
    					try {
    					bw.close();
    				} catch (IOException ioe2) {
    					System.out.println("Error writing system log.");
    					ioe2.printStackTrace();
    				}
    			}
    		}
    In client.java you need to declare
    Code:
    import java.io.BufferedWriter;
    import java.io.IOException;
    http://www.rune-server.org/showthrea...68#post1033168

    You should be able to figure it out from that...
    Reply With Quote  
     

  5. #5  
    Member bufferedwriter wont write. Market Banned


    Luke132's Avatar
    Join Date
    Dec 2007
    Age
    35
    Posts
    12,574
    Thanks given
    199
    Thanks received
    7,106
    Rep Power
    5000
    flush + close

    Attached imageAttached image
    Reply With Quote  
     

  6. #6  
    Banned

    Join Date
    Jul 2008
    Age
    28
    Posts
    5,827
    Thanks given
    1,301
    Thanks received
    197
    Rep Power
    0
    ok like it deletes whats already in the file... im making logs, so how do i make it not delete whats already there?
    Reply With Quote  
     

  7. #7  
    Registered Member

    Join Date
    Jan 2009
    Posts
    274
    Thanks given
    0
    Thanks received
    2
    Rep Power
    97
    Quote Originally Posted by Blood Runna View Post
    ok like it deletes whats already in the file... im making logs, so how do i make it not delete whats already there?
    Just take a look at what I posted, read the script, learn from it, it's banning script, so it adds a new line / doesn't delete etc etc.
    Reply With Quote  
     

  8. #8  
    Banned

    Join Date
    Jul 2008
    Age
    28
    Posts
    5,827
    Thanks given
    1,301
    Thanks received
    197
    Rep Power
    0
    that method overwrites the file. im making a chat log and it only puts the last line typed in there.
    Reply With Quote  
     

  9. #9  
    Registered Member
    Core's Avatar
    Join Date
    Sep 2007
    Posts
    4,194
    Thanks given
    11
    Thanks received
    393
    Rep Power
    1985
    Code:
    bw.newLine();
    bw.flush();
    Reply With Quote  
     


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
  •