本文整理匯總了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;
}