本文整理汇总了Java中com.badlogic.gdx.utils.ByteArray类的典型用法代码示例。如果您正苦于以下问题:Java ByteArray类的具体用法?Java ByteArray怎么用?Java ByteArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ByteArray类属于com.badlogic.gdx.utils包,在下文中一共展示了ByteArray类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import com.badlogic.gdx.utils.ByteArray; //导入依赖的package包/类
@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));
}
}
示例2: read
import com.badlogic.gdx.utils.ByteArray; //导入依赖的package包/类
@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;
}
示例3: getRootDir
import com.badlogic.gdx.utils.ByteArray; //导入依赖的package包/类
@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);
}