Java tutorial
//package com.java2s; import java.io.BufferedReader; import java.io.IOException; public class Main { public static String getNextSection(BufferedReader bufferedReader) throws IOException { String buffer; do { buffer = bufferedReader.readLine(); if (buffer == null) { return null; } buffer = buffer.trim(); } while (!buffer.matches("\\[.*\\]")); return buffer.substring(1, buffer.length() - 1); } }