public String readNestedContents(Reader r) throws IOException {
  StringBuffer contents=new StringBuffer();
  int parOpen;
  char c='\0';
  skipUntil(r,'(');
  parOpen=1;
  while (c != (char)-1 && parOpen > 0) {
    c=(char)r.read();
    if (c == '(') {
      parOpen++;
    }
    if (c == ')') {
      parOpen--;
    }
    if (Character.isWhitespace(c)) {
      c=' ';
    }
    contents.append(c);
  }
  contents.deleteCharAt(contents.length() - 1);
  return contents.toString();
}

public String readNestedContents ( Reader r ) throws IOException { StringBuffer contents = new StringBuffer ( ) ; int parOpen ; char c = '\0' ; skipUntil ( r , '(' ) ; parOpen = 1 ; while ( c != ( char ) - 1 && parOpen > 0 ) { c = ( char ) r . read ( ) ; if ( c == '(' ) { parOpen ++ ; } if ( c == ')' ) { parOpen -- ; } if ( Character . isWhitespace ( c ) ) { c = ' ' ; } contents . append ( c ) ; } contents . deleteCharAt ( contents . length ( ) - 1 ) ; return contents . toString ( ) ; }
reads everything from the first opening parenthesis until line that ends to a closing parenthesis and returns the contents in one string
