code: public static String trimLines(String text) {
          if (text == null) {
              return null;
          }
  
          try {
              StringBuffer output = new StringBuffer();
  
              // First we strip multi line comments. I think this is important:
              BufferedReader in = new BufferedReader(new StringReader(text));
              while (true) {
                  String line = in.readLine();
                  if (line == null) {
                      break;
                  }
  
                  output.append(line.trim());
                  output.append('\n');
              }
  
              return output.toString();
          } catch (IOException e) {
              throw new IllegalArgumentException(e);
          }
      }
docs: Remove any leading or trailing spaces from a line of code.
  This function could be improved by making it strip unnecessary double
  spaces, but since we would need to leave double spaces inside strings
  this is not simple and since the benefit is small, we'll leave it for now
  @param text The javascript program to strip spaces from.
  @return The stripped program