Java tutorial
//package com.java2s; import java.io.IOException; import java.io.StringReader; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date readDate(StringReader reader, char delimiter) throws ParseException { String date = readString(reader, ','); try { return new SimpleDateFormat("H.mm").parse(date); } catch (ParseException e) { throw new IllegalArgumentException( "Malformed Compressed Market Data: Could not parse the date from " + date); } } public static String readString(StringReader sr, char delimiter) { try { StringBuilder sb = new StringBuilder(); char c; while ((c = (char) sr.read()) != (char) -1) { if (c == '\\') { // This is an escape character. Jump past to the next char. sb.append((char) sr.read()); } else if (c == delimiter) { break; } else { sb.append(c); } } return sb.toString(); } catch (IOException e) { // Cannot happen as there is no IO here - just a read from a string throw new RuntimeException("Unexpected IOException", e); } } }