本文整理汇总了Java中com.dd.plist.BinaryPropertyListWriter类的典型用法代码示例。如果您正苦于以下问题:Java BinaryPropertyListWriter类的具体用法?Java BinaryPropertyListWriter怎么用?Java BinaryPropertyListWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BinaryPropertyListWriter类属于com.dd.plist包,在下文中一共展示了BinaryPropertyListWriter类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendMessage
import com.dd.plist.BinaryPropertyListWriter; //导入依赖的package包/类
@Override
public void sendMessage(NSDictionary message) throws IOException {
byte[] messageBytes = BinaryPropertyListWriter.writeToArray(message);
byte[] lengthBytes = Ints.toByteArray(messageBytes.length);
socketOut.write(lengthBytes);
socketOut.write(messageBytes);
}
示例2: testReceiveMessage
import com.dd.plist.BinaryPropertyListWriter; //导入依赖的package包/类
@Test
public void testReceiveMessage() throws IOException {
NSDictionary inputMessage = new NSDictionary();
inputMessage.put("goodbye", "world");
byte[] messageBytes = BinaryPropertyListWriter.writeToArray(inputMessage);
byte[] lengthBytes = Ints.toByteArray(messageBytes.length);
byte[] inputBytes = new byte[messageBytes.length + 4];
System.arraycopy(lengthBytes, 0, inputBytes, 0, 4);
System.arraycopy(messageBytes, 0, inputBytes, 4, messageBytes.length);
FakeSocket fakeSocket = new FakeSocket(inputBytes);
try (InspectorSocket socket = new BinaryPlistSocket(fakeSocket)) {
assertThat(socket.receiveMessage().get()).isEqualTo(inputMessage);
}
}
示例3: testReceiveEOF
import com.dd.plist.BinaryPropertyListWriter; //导入依赖的package包/类
@Test
public void testReceiveEOF() throws IOException {
NSDictionary inputMessage = new NSDictionary();
inputMessage.put("goodbye", "world");
byte[] messageBytes = BinaryPropertyListWriter.writeToArray(inputMessage);
byte[] lengthBytes = Ints.toByteArray(messageBytes.length + 1);
byte[] inputBytes = new byte[messageBytes.length + 4];
System.arraycopy(lengthBytes, 0, inputBytes, 0, 4);
System.arraycopy(messageBytes, 0, inputBytes, 4, messageBytes.length);
FakeSocket fakeSocket = new FakeSocket(inputBytes);
try (InspectorSocket socket = new BinaryPlistSocket(fakeSocket)) {
assertThat(socket.receiveMessage().isPresent()).isFalse();
}
}
示例4: writePlist
import com.dd.plist.BinaryPropertyListWriter; //导入依赖的package包/类
/**
* Writes the results of a merge operation to a binary plist file.
* @param plistPath the path of the plist to write in binary format
*/
public PlistMerging writePlist(Path plistPath) throws IOException {
try (OutputStream out = Files.newOutputStream(plistPath)) {
BinaryPropertyListWriter.write(out, merged);
}
return this;
}