int last = 0; int i = 0; while (i < tagSize)
for (int last = 0, i = 0, n = 0; n < tagSize; n++)
    private void readTag (InputStream in)    throws IOException, Exception    {	// read header	header = new byte[10];	in.read(header);	if (header[0] != 'I' || header[1] != 'D' || header[2] != '3') return;	// extract header info	minor = (int) header[3];	revis = (int) header[4];	bits = (int) header[5];	unsyncFlag = (bits & 0x80) != 0;	extFlag = (bits & 0x40) != 0; // TODO handle extended headers	expFlag = (bits & 0x20) != 0;	footerFlag = (bits & 0x10) != 0; // TODO handle footer	tagLength = Frame.unsynchInteger(header, 6);	// read tag data	int tagSize = tagLength; // - (footerFlag ? 20 : 10);	byte[] tagData = new byte[tagSize];	if (unsyncFlag)	{	    int last = 0;	    int i = 0;	    while (i < tagSize)	    {		int b = in.read();		if (b == -1)		{		    System.out.println("OEPS.. "+tagLength+", "+i);		    tagLength = i;		    break;		}		if (! (last == 0xff && b == 0)) tagData[i++] = (byte) b;		last = b;	    }	}	else	{	    in.read(tagData);	}	in.close();	// collect frames	int bytesRead = 0;	frames = new Vector();	while (bytesRead < tagSize)	{	    if (! Character.isLetterOrDigit((char)tagData[bytesRead])) break;	    // read frame identifier	    StringBuffer sb = new StringBuffer();	    sb.append((char)tagData[bytesRead]);	    sb.append((char)tagData[bytesRead+1]);	    sb.append((char)tagData[bytesRead+2]);	    sb.append((char)tagData[bytesRead+3]);	    String id = sb.toString();	    // determine frame type	    Frame frame;	    if (! id.equals("TXXX") && id.startsWith("T"))	    {		frame = new TextFrame(tagData, bytesRead, minor);	    }	    else if (id.equals("COMM") || id.equals("USLT"))	    {		frame = new TextFrame(tagData, bytesRead, minor, TextFrame.LANGUAGE);	    }	    else if (id.startsWith("W"))	    {		frame = new LinkFrame(tagData, bytesRead, minor);	    }	    else if (id.startsWith("APIC"))	    {		frame = new PictureFrame(tagData, bytesRead, minor);	    }	    else	    {		frame = new Frame(tagData, bytesRead, minor);	    }	    frames.add(frame);	    bytesRead += frame.getLength();	}	// tag successfully read	tagAvailable = true;    }