[cr] in chat

Discussion in 'Plugin Development' started by puppy3276, Mar 15, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    puppy3276

    This works but at the end of every line except the last there is a cr in a square. What do I have wrong?


    Im filename I have:
    Code:
    line1
    line2
    line3 
    OnPlayerJoin I have:
    Code:
    player.sendMessage(readEntireFile(filename))
    ReadEntireFile Class
    Code:
    private static String readEntireFile(String filename) throws IOException {
            FileReader in = new FileReader(filename);
            StringBuilder contents = new StringBuilder();
            char[] buffer = new char[4096];
            int read = 0;
            do {
                contents.append(buffer, 0, read);
                read = in.read(buffer);
            } while (read >= 0);
            return contents.toString();
        }
     
  2. Offline

    kreashenz

    Use :
    (message).replaceAll("[", " ");
    (message).replaceAll("]", " ");
     
  3. Offline

    puppy3276

    kreashenz Wouldn't that replace brackets?

    Its not [cr] Its cr in an actual square.

    anyone?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  4. Offline

    Digi

    That stands for carriage return, it's the \r character.

    You should either read the file line by line or strip the \r character.

    And depending on the OS and the editor used, it may also append a \n (or the other way around, I dunno), you should also replace that character as well.

    But my recomendation is that you read the file line by line, I belive there must be a method there.
     
  5. Offline

    Shevchik

    it's an \r symbol i think, which is added to the end of every line on windows
     
  6. Offline

    ZeusAllMighty11 Retired Staff

    Shevchik

    I like how you edited your post to copy Digi's.
     
  7. Offline

    Shevchik

    There was a message about microsoft is gay for using \r\n as a signal of the end of line and not just \n
     
Thread Status:
Not open for further replies.

Share This Page