Java tutorial
//package com.java2s; import java.io.*; public class Main { /** * Reads all text up to next XML tag and returns it as a String. * * @return the String of the text read, which may be empty. */ public static String readUntilTag(Reader r) throws IOException { if (!r.ready()) { return ""; } StringBuilder b = new StringBuilder(); int c = r.read(); while (c >= 0 && c != '<') { b.append((char) c); c = r.read(); } return b.toString(); } }