Java tutorial
//package com.java2s; import java.io.*; public class Main { /** * Reads all text of the XML tag and returns it as a String. * Assumes that a '<' character has already been read. * * @param r The reader to read from * @return The String representing the tag, or null if one couldn't be read * (i.e., EOF). The returned item is a complete tag including angle * brackets, such as <code><TXT></code> */ public static String readTag(Reader r) throws IOException { if (!r.ready()) { return null; } StringBuilder b = new StringBuilder("<"); int c = r.read(); while (c >= 0) { b.append((char) c); if (c == '>') { break; } c = r.read(); } if (b.length() == 1) { return null; } return b.toString(); } }