手机版

Java数据库处理的方法库DBUtil(5)

时间:2025-04-27   来源:未知    
字号:

b.DBUtil:Oracle、Postegres、Caasndra等数据库的访问执行方法 c.EncryptionUtil:加密算法,包括md5编码等。

后续还会继续完善各种协议的方法库,并在推广并公测一段时间后将以jar包的方式提供API接口调用。

1.将不同的byte[]字节数组流打包成一个字节数组

public static byte[] pack(byte[] agrs) throws IOException{ ByteArrayOutputStream bout = new ByteArrayOutputStream(); for(byte[] b:agrs){

bout.write(b);

}

byte[] buff = bout.toByteArray();

return buff;

}

2.在byte字节流中搜索指定字节流的位置,采用KMP算法实现。

/**取到字节流中指定字节流的位置

* The Knuth-Morris-Pratt Pattern Matching Algorithm can be used to search a byte array.

* Search the data byte array for the first occurrence

* of the byte array pattern.

*/

public static int indexOf(byte[] data, byte[] pattern) {

int[] failure = computeFailure(pattern);

int j = 0;

for (int i = 0; i < data.length; i++) {

while (j > 0 && pattern[j] != data[i]) {

j = failure[j - 1];

}

if (pattern[j] == data[i]) {

j++;

}

if (j == pattern.length) {

return i + 1;

//return i – pattern.length + 1;

}

}

return -1;

}

/**

* Computes the failure function using a boot-strapping process, * where the pattern is matched against itself.

Java数据库处理的方法库DBUtil(5).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
×
二维码
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)