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(); }
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.
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.
There was a message about microsoft is gay for using \r\n as a signal of the end of line and not just \n