use of com.hankcs.hanlp.corpus.io.ByteArray in project HanLP by hankcs.
the class TestBytesArray method testLoadByteArray.
/**
* 无法在-Xms512m -Xmx512m -Xmn256m下运行<br>
* java.lang.OutOfMemoryError: GC overhead limit exceeded
* @throws Exception
*/
public void testLoadByteArray() throws Exception {
ByteArray byteArray = ByteArray.createByteArray(HanLP.Config.MaxEntModelPath + Predefine.BIN_EXT);
MaxEntModel.create(byteArray);
}
use of com.hankcs.hanlp.corpus.io.ByteArray in project HanLP by hankcs.
the class ByteUtilTest method testReadDouble.
public void testReadDouble() throws Exception {
DataOutputStream out = new DataOutputStream(new FileOutputStream(DATA_TEST_OUT_BIN));
out.writeDouble(0.123456789);
out.writeInt(3389);
ByteArray byteArray = ByteArray.createByteArray(DATA_TEST_OUT_BIN);
System.out.println(byteArray.nextDouble());
System.out.println(byteArray.nextInt());
}
use of com.hankcs.hanlp.corpus.io.ByteArray in project HanLP by hankcs.
the class ByteUtilTest method testReadUTF.
public void testReadUTF() throws Exception {
DataOutputStream out = new DataOutputStream(new FileOutputStream(DATA_TEST_OUT_BIN));
out.writeUTF("hankcs你好123");
ByteArray byteArray = ByteArray.createByteArray(DATA_TEST_OUT_BIN);
System.out.println(byteArray.nextUTF());
}
use of com.hankcs.hanlp.corpus.io.ByteArray in project HanLP by hankcs.
the class ByteUtilTest method testReadUnsignedShort.
public void testReadUnsignedShort() throws Exception {
DataOutputStream out = new DataOutputStream(new FileOutputStream(DATA_TEST_OUT_BIN));
int utflen = 123;
out.writeByte((byte) ((utflen >>> 8) & 0xFF));
out.writeByte((byte) ((utflen >>> 0) & 0xFF));
ByteArray byteArray = ByteArray.createByteArray(DATA_TEST_OUT_BIN);
System.out.println(byteArray.nextUnsignedShort());
}
use of com.hankcs.hanlp.corpus.io.ByteArray in project HanLP by hankcs.
the class TestBytesArray method testWriteAndRead.
public void testWriteAndRead() throws Exception {
DataOutputStream out = new DataOutputStream(new FileOutputStream(DATA_OUT_DAT));
out.writeChar('H');
out.writeChar('e');
out.writeChar('l');
out.writeChar('l');
out.writeChar('o');
out.close();
ByteArray byteArray = ByteArray.createByteArray(DATA_OUT_DAT);
while (byteArray.hasMore()) {
System.out.println(byteArray.nextChar());
}
}
Aggregations