本文整理汇总了Java中org.hsqldb.lib.ArrayUtil.countNonStartElementsAt方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtil.countNonStartElementsAt方法的具体用法?Java ArrayUtil.countNonStartElementsAt怎么用?Java ArrayUtil.countNonStartElementsAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hsqldb.lib.ArrayUtil
的用法示例。
在下文中一共展示了ArrayUtil.countNonStartElementsAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.hsqldb.lib.ArrayUtil; //导入方法依赖的package包/类
/**
* Causes this WebServerConnection to process its HTTP request
* in a blocking fashion until the request is fully processed
* or an exception occurs internally.
*
* This method reads the Request line then delegates action to subroutines.
*/
public void run() {
try {
DataInputStream inStream =
new DataInputStream(socket.getInputStream());
int count;
String request;
String name = null;
int method = REQUEST_TYPE_BAD;
int len = -1;
// read line, ignoring any leading blank lines
do {
count = InOutUtil.readLine(inStream, rowOut);
if (count == 0) {
throw new Exception();
}
} while (count < 2);
byte[] byteArray = rowOut.getBuffer();
int offset = rowOut.size() - count;
if (ArrayUtil.containsAt(byteArray, offset, BYTES_POST)) {
method = REQUEST_TYPE_POST;
offset += BYTES_POST.length;
} else if (ArrayUtil.containsAt(byteArray, offset, BYTES_GET)) {
method = REQUEST_TYPE_GET;
offset += BYTES_GET.length;
} else if (ArrayUtil.containsAt(byteArray, offset, BYTES_HEAD)) {
method = REQUEST_TYPE_HEAD;
offset += BYTES_HEAD.length;
} else {
throw new Exception();
}
count = ArrayUtil.countStartElementsAt(byteArray, offset,
BYTES_WHITESPACE);
if (count == 0) {
throw new Exception();
}
offset += count;
count = ArrayUtil.countNonStartElementsAt(byteArray, offset,
BYTES_WHITESPACE);
name = new String(byteArray, offset, count, ENCODING);
switch (method) {
case REQUEST_TYPE_BAD :
processError(REQUEST_TYPE_BAD);
break;
case REQUEST_TYPE_GET :
processGet(name, true);
break;
case REQUEST_TYPE_HEAD :
processGet(name, false);
break;
case REQUEST_TYPE_POST :
processPost(inStream, name);
break;
}
inStream.close();
socket.close();
} catch (Exception e) {
server.printStackTrace(e);
}
}