byte[] pngBuffer = new byte[ pngLength ]; in.read( pngBuffer );
byte[] pngBuffer = new byte[ pngLength ];    int offset = 0; int read = 0; while (offset < pngLength) { read = in.read( pngBuffer, offset, pngLength - offset ); if (read == -1) { break; } else { offset += read; } }
	public BitMapFontViewer getViewer( String input ) {		if (this.fontImage == null) {			// try to load the *.bmf file:			InputStream in = null;			try {				in = getClass().getResourceAsStream(this.fontUrl);				if (in == null) {					return null;				}				DataInputStream dataIn = new DataInputStream( in );				this.hasMixedCase = dataIn.readBoolean();				String map = dataIn.readUTF();				this.characterMap = map;				this.spaceIndex = map.indexOf(' ');				int length = map.length();				this.characterWidths = new byte[ length ];				this.xPositions = new short[ length ];				short xPos = 0;				for (int i = 0; i < length; i++ ) {					byte width = dataIn.readByte();					this.characterWidths[i] = width;					this.xPositions[i] = xPos;					xPos += width;				}				//#ifdef polish.midp2					this.fontImage = Image.createImage( in );				//#else					int pngLength = in.available();					byte[] pngBuffer = new byte[ pngLength ]; 					in.read( pngBuffer );					this.fontImage = Image.createImage(pngBuffer, 0, pngLength);				//#endif				this.fontHeight = this.fontImage.getHeight();				this.fontUrl = null;			} catch (IOException e) {				//#debug error				System.out.println("Unable to load bitmap-font [" + this.fontUrl + "]" + e);				return null;			} finally {				try { 					in.close();				} catch (IOException e) {					//#debug error					System.out.println("Unable to close bitmap-font stream" + e);				}			}		}		//int imageWidth = this.fontImage.getWidth();		// get the x/y-position and width for each character:		if (!this.hasMixedCase) {			input = input.toLowerCase();		}		int length = input.length();		//short[] yPositions = new short[ length ];		int[] indeces = new int[ length ];		for (int i = length - 1; i >= 0; i-- ) {			char inputCharacter = input.charAt(i);			if (inputCharacter == '\n') {				indeces[i] = BitMapFontViewer.ABSOLUTE_LINE_BREAK;			} else {				indeces[i] = this.characterMap.indexOf( inputCharacter );			}		}		return new BitMapFontViewer( this.fontImage, indeces, this.xPositions, this.characterWidths, this.fontHeight, this.spaceIndex, 1 );	}