Java 类com.badlogic.gdx.utils.ByteArray 实例源码

项目:gdx-cclibs    文件:ByteArraySerializer.java   
@Override
public void write(Kryo kryo, Output output, ByteArray array) {
    output.writeVarInt(array.size, true);
    output.writeBoolean(array.ordered);
    for (int i = 0; i < array.size; i++) {
        output.writeByte(array.get(i));
    }
}
项目:gdx-cclibs    文件:ByteArraySerializer.java   
@Override
public ByteArray read(Kryo kryo, Input input, Class<ByteArray> type) {
    int length = input.readVarInt(true);
    boolean ordered = input.readBoolean();
    ByteArray array = new ByteArray(ordered, length);
    for (int i = 0; i < length; i++) {
        array.add(input.readByte());
    }
    return array;
}
项目:cachebox3.0    文件:FileBrowserTest.java   
@Test
void getRootDir() throws InterruptedException {

    if (EXCLUDE_FROM_TRAVIS.VALUE) return;

    assertThat("Connection must be established", clint.connect());
    assertThat("Connection must be established", clint.connect());
    ServerFile root = clint.getFiles();
    ServerFileTest.assertRecursiveDir(workpath, root, workpath.parent().path());


    FileHandle file = workpath.child("lang/de/strings.ini");
    String sendPath = "sendTest/de";
    ServerFile serverFile = new ServerFile("", sendPath, true);
    FileHandle targetFile = workpath.child(sendPath).child("strings.ini");

    if (targetFile.exists()) {
        // delete test file
        targetFile.parent().parent().deleteDirectory();
        assertThat("transmitted File must delete", !targetFile.exists());
    }

    Thread.sleep(100);

    ArrayList<File> fileList = new ArrayList<>();
    fileList.add(file.file());

    try {
        assertThat("sendFiles must return true", clint.sendFiles(null, serverFile, root, fileList));
    } catch (Exception e) {
        e.printStackTrace();
    }

    Thread.sleep(100);

    assertThat("transmitted File must exist", targetFile.exists());
    assertThat("File.length must equals", targetFile.length() == file.length());

    ByteArray a1 = new ByteArray(targetFile.readBytes());
    ByteArray a2 = new ByteArray(file.readBytes());


    assertThat("File Content must equals", a1.equals(a2));


    // delete test file
    targetFile.parent().parent().deleteDirectory();
    assertThat("transmitted File must delete", !targetFile.exists());

    Thread.sleep(100);
}