private static void appendNewlineIfNecessary(StringBuffer buf,Writer out) throws IOException {
  int len=buf.length();
  if ((len != 0) && (buf.charAt(len - 1) != '\n')) {
    out.write('\n');
  }
}

private static void appendNewlineIfNecessary ( StringBuffer buf , Writer out ) throws IOException { int len = buf . length ( ) ; if ( ( len != 0 ) && ( buf . charAt ( len - 1 ) != '\n' ) ) { out . write ( '\n' ) ; } }
appends a newline to the given buffer via the given writer , but only if it isn ' t empty and doesn ' t already end with one .
