/** * A static method to write a line to a BufferedOutputStream and then pass the line to the log * method of the supplied PircBot instance. * * @param bot The underlying PircBot instance. * @param out The BufferedOutputStream to write to. * @param line The line to be written. "\r\n" is appended to the end. * @param encoding The charset to use when encoing this string into a byte array. */ static void sendRawLine(PircBot bot, BufferedWriter bwriter, String line) { if (line.length() > bot.getMaxLineLength() - 2) { line = line.substring(0, bot.getMaxLineLength() - 2); } synchronized (bwriter) { try { bwriter.write(line + "\r\n"); bwriter.flush(); bot.log(">>>" + line); } catch (Exception e) { // Silent response - just lose the line. } } }