while (end < buffer.length()) { String s = buffer.substring(start, end);
while (end < string.length()) { String s = string.substring(start, end);
public Object nativeToJava(TransferData transferData){	if (!isSupportedType(transferData) || transferData.pIDataObject == 0) return null;	IDataObject data = new IDataObject(transferData.pIDataObject);	data.AddRef();	STGMEDIUM stgmedium = new STGMEDIUM();	FORMATETC formatetc = transferData.formatetc;	stgmedium.tymed = COM.TYMED_HGLOBAL;		transferData.result = data.GetData(formatetc, stgmedium);	data.Release();		if (transferData.result != COM.S_OK) return null;	int hMem = stgmedium.unionField;		try {		int lpMultiByteStr = OS.GlobalLock(hMem);		if (lpMultiByteStr == 0) return null;		try {			int codePage = OS.GetACP();			int cchWideChar  = OS.MultiByteToWideChar (codePage, OS.MB_PRECOMPOSED, lpMultiByteStr, -1, null, 0);			if (cchWideChar == 0) return null;			char[] lpWideCharStr = new char [cchWideChar - 1];			OS.MultiByteToWideChar (codePage, OS.MB_PRECOMPOSED, lpMultiByteStr, -1, lpWideCharStr, lpWideCharStr.length);			StringBuffer buffer = new StringBuffer(new String(lpWideCharStr));			int fragmentStart = 0, fragmentEnd = 0;			int start = buffer.indexOf(StartFragment) + StartFragment.length();			int end = start + 1;			while (end < buffer.length()) { 				String s = buffer.substring(start, end);				try {					fragmentStart = Integer.parseInt(s);					end++;				} catch (NumberFormatException e) {					break;				}			}			start = buffer.indexOf(EndFragment) + EndFragment.length();			end = start + 1;			while (end < buffer.length()) { 				String s = buffer.substring(start, end);				try {					fragmentEnd = Integer.parseInt(s);					end++;				} catch (NumberFormatException e) {					break;				}			}			if (fragmentEnd <= fragmentStart || fragmentEnd > lpWideCharStr.length) return null;			/* TO DO:			 * FragmentStart and FragmentEnd are offsets in original byte stream, not			 * the wide char version of the byte stream.			 */			String s = buffer.substring(fragmentStart, fragmentEnd);			/*			 * Firefox includes <!--StartFragment --> in the fragment, so remove it.			 */			String foxStart = "<!--StartFragment -->\r\n"; //$NON-NLS-1$			int prefix = s.indexOf(foxStart);			if (prefix != -1) {				prefix += foxStart.length();				s = s.substring(prefix);			}			return s;		} finally {			OS.GlobalUnlock(hMem);		}	} finally {		OS.GlobalFree(hMem);	}}