org.apache.commons.io.IOExceptionWithCause Java Examples
The following examples show how to use
org.apache.commons.io.IOExceptionWithCause.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RawRequestSourcePreProcessor.java From jmeter-plugins with Apache License 2.0 | 5 votes |
private int getNextChunkSize() throws IOException { metaBuf.clear(); while (true) { byte b = getOneByte(); if (b == 10 || b == 13) { // if we have \r\n then skip \n byte b2 = getOneByte(); if (b2 != 10) { file.position(file.position() - 1); } // ignore newlines before length marker if (metaBuf.position() > 0) { break; } } else { //if (log.isDebugEnabled()) log.debug("Read byte: "+b); metaBuf.put(b); } } //if (log.isDebugEnabled()) log.debug("Meta line: "+JMeterPluginsUtils.byteBufferToString(metaBuf)); byte[] bLine = new byte[metaBuf.position()]; metaBuf.rewind(); metaBuf.get(bLine); String sLine = new String(bLine).trim(); String[] ar = sLine.split(regexp); if (log.isDebugEnabled()) { log.debug("Chunk size: " + ar[0]); } int res = 0; try { res = Integer.parseInt(ar[0]); } catch (NumberFormatException ex) { log.error("Error reading chunk size near: " + sLine, ex); throw new IOExceptionWithCause(ex); } return res; }