本文整理了Java中java.io.DataOutputStream.writeBoolean()
方法的一些代码示例,展示了DataOutputStream.writeBoolean()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DataOutputStream.writeBoolean()
方法的具体详情如下:
包路径:java.io.DataOutputStream
类名称:DataOutputStream
方法名:writeBoolean
[英]Writes a boolean to the target stream.
[中]将布尔值写入目标流。
代码示例来源:origin: hankcs/HanLP
@Override
public void save(DataOutputStream out) throws IOException
{
out.writeInt(size);
for (int i = 0; i < size; i++)
{
out.writeInt(data[i]);
}
out.writeInt(linearExpandFactor);
out.writeBoolean(exponentialExpanding);
out.writeDouble(exponentialExpandFactor);
}
代码示例来源:origin: google/ExoPlayer
@Override
protected void writeToStream(DataOutputStream output) throws IOException {
output.writeUTF(uri.toString());
output.writeBoolean(isRemoveAction);
output.writeInt(data.length);
output.write(data);
boolean customCacheKeySet = customCacheKey != null;
output.writeBoolean(customCacheKeySet);
if (customCacheKeySet) {
output.writeUTF(customCacheKey);
}
}
代码示例来源:origin: btraceio/btrace
private static void writeMethodInv(MethodInsnNode min, DataOutputStream dos) throws IOException {
dos.writeUTF(min.owner);
dos.writeUTF(min.name);
dos.writeUTF(min.desc);
dos.writeBoolean(min.itf);
}
代码示例来源:origin: apache/nifi
private byte[] serialize(final Map<String, String> stateValues) throws IOException {
try (final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final DataOutputStream dos = new DataOutputStream(baos)) {
dos.writeByte(ENCODING_VERSION);
dos.writeInt(stateValues.size());
for (final Map.Entry<String, String> entry : stateValues.entrySet()) {
final boolean hasKey = entry.getKey() != null;
final boolean hasValue = entry.getValue() != null;
dos.writeBoolean(hasKey);
if (hasKey) {
dos.writeUTF(entry.getKey());
}
dos.writeBoolean(hasValue);
if (hasValue) {
dos.writeUTF(entry.getValue());
}
}
return baos.toByteArray();
}
}
代码示例来源:origin: libgdx/libgdx
public RemoteSender (String ip, int port) {
try {
Socket socket = new Socket(ip, port);
socket.setTcpNoDelay(true);
socket.setSoTimeout(3000);
out = new DataOutputStream(socket.getOutputStream());
out.writeBoolean(Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen));
connected = true;
Gdx.input.setInputProcessor(this);
} catch (Exception e) {
Gdx.app.log("RemoteSender", "couldn't connect to " + ip + ":" + port);
}
}
代码示例来源:origin: stackoverflow.com
File file = new File("C:/text.bin");
file.createNewFile();
DataOutputStream stream = new DataOutputStream(new FileOutputStream(file));
stream.writeBoolean(true);
stream.writeInt(1234);
stream.close();
代码示例来源:origin: apache/accumulo
private byte[] encode() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
dos.writeLong(creationTime);
dos.writeBoolean(server != null);
if (server != null) {
dos.writeUTF(server);
}
dos.writeBoolean(exception != null);
if (exception != null) {
dos.writeUTF(exception);
}
dos.close();
baos.close();
return baos.toByteArray();
}
代码示例来源:origin: google/ExoPlayer
@Override
public final void writeToStream(DataOutputStream output) throws IOException {
output.writeUTF(uri.toString());
output.writeBoolean(isRemoveAction);
output.writeInt(data.length);
output.write(data);
output.writeInt(keys.size());
for (int i = 0; i < keys.size(); i++) {
writeKey(output, keys.get(i));
}
}
代码示例来源:origin: google/ExoPlayer
private static void doTestSerializationV0RoundTrip(HlsDownloadAction action) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(out);
DataOutputStream dataOutputStream = new DataOutputStream(output);
dataOutputStream.writeUTF(action.type);
dataOutputStream.writeInt(/* version */ 0);
dataOutputStream.writeUTF(action.uri.toString());
dataOutputStream.writeBoolean(action.isRemoveAction);
dataOutputStream.writeInt(action.data.length);
dataOutputStream.write(action.data);
dataOutputStream.writeInt(action.keys.size());
for (int i = 0; i < action.keys.size(); i++) {
StreamKey key = action.keys.get(i);
dataOutputStream.writeInt(key.groupIndex);
dataOutputStream.writeInt(key.trackIndex);
}
dataOutputStream.flush();
assertEqual(action, deserializeActionFromStream(out));
}
代码示例来源:origin: libgdx/libgdx
public RemoteSender (String ip, int port) {
try {
Socket socket = new Socket(ip, port);
socket.setTcpNoDelay(true);
socket.setSoTimeout(3000);
out = new DataOutputStream(socket.getOutputStream());
out.writeBoolean(Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen));
connected = true;
Gdx.input.setInputProcessor(this);
} catch (Exception e) {
Gdx.app.log("RemoteSender", "couldn't connect to " + ip + ":" + port);
}
}
代码示例来源:origin: org.apache.hadoop/hadoop-common
} else if (clientVersion == 2) { // Hadoop 0.18.3
RpcCall fakeCall = new RpcCall(this, 0);
DataOutputStream out = new DataOutputStream(buffer);
out.writeInt(0); // call ID
out.writeBoolean(true); // error
WritableUtils.writeString(out, VersionMismatch.class.getName());
WritableUtils.writeString(out, errMsg);
代码示例来源:origin: marytts/marytts
dos.writeBoolean(useJampackInAnalysis);
dos.writeBoolean(isSilentAnalysis);
dos.writeInt(harmonicModel);
dos.writeInt(noiseModel);
dos.writeBoolean(useHarmonicAmplitudesDirectly);
dos.writeFloat(regularizedCepstrumLambdaHarmonic);
dos.writeBoolean(useWeightingInRegularizedCepstrumEstimationHarmonic);
dos.writeInt(harmonicPartCepstrumOrderPreMel);
dos.writeInt(harmonicPartCepstrumOrder);
dos.writeBoolean(computeNoisePartLpOrderFromSamplingRate);
dos.writeInt(noisePartLpOrder);
dos.writeFloat(preemphasisCoefNoise);
dos.writeBoolean(hpfBeforeNoiseAnalysis);
dos.writeBoolean(decimateNoiseWaveform);
dos.writeBoolean(overlapNoiseWaveformModel);
dos.writeBoolean(useNoiseAmplitudesDirectly);
dos.writeFloat(regularizedCepstrumEstimationLambdaNoise);
dos.writeBoolean(useWeightingInRegularizedCesptrumEstimationNoise);
dos.writeInt(noisePartCepstrumOderPre);
dos.writeInt(noisePartCepstrumOrder);
dos.writeBoolean(usePosteriorMelWarpingNoise);
代码示例来源:origin: apache/tika
private void sendString(String string) throws SAXException {
try {
if (string != null) {
output.writeBoolean(true);
output.writeUTF(string);
} else {
output.writeBoolean(false);
}
} catch (IOException e) {
throw new SAXException("Unexpected fork proxy problem", e);
}
}
代码示例来源:origin: apache/geode
private void writeGraphName(Object graphName) throws IOException {
boolean isPattern = graphName instanceof Pattern;
outputStream.writeBoolean(isPattern);
if (isPattern) {
final Pattern pattern = (Pattern) graphName;
outputStream.writeUTF(pattern.pattern());
outputStream.writeInt(pattern.flags());
} else {
outputStream.writeUTF(graphName.toString());
}
}
代码示例来源:origin: google/ExoPlayer
private static void doTestSerializationV0RoundTrip(SsDownloadAction action) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(out);
DataOutputStream dataOutputStream = new DataOutputStream(output);
dataOutputStream.writeUTF(action.type);
dataOutputStream.writeInt(/* version */ 0);
dataOutputStream.writeUTF(action.uri.toString());
dataOutputStream.writeBoolean(action.isRemoveAction);
dataOutputStream.writeInt(action.data.length);
dataOutputStream.write(action.data);
dataOutputStream.writeInt(action.keys.size());
for (int i = 0; i < action.keys.size(); i++) {
StreamKey key = action.keys.get(i);
dataOutputStream.writeInt(key.groupIndex);
dataOutputStream.writeInt(key.trackIndex);
}
dataOutputStream.flush();
assertEqual(action, deserializeActionFromStream(out));
}
代码示例来源:origin: apache/zookeeper
@Override
public void revalidateSession(QuorumPacket qp, LearnerHandler learnerHandler) throws IOException {
ByteArrayInputStream bis = new ByteArrayInputStream(qp.getData());
DataInputStream dis = new DataInputStream(bis);
long id = dis.readLong();
int to = dis.readInt();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
dos.writeLong(id);
boolean valid = zk.checkIfValidGlobalSession(id, to);
if (valid) {
try {
// set the session owner as the follower that owns the session
zk.setOwner(id, learnerHandler);
} catch (KeeperException.SessionExpiredException e) {
LOG.error("Somehow session " + Long.toHexString(id) + " expired right after being renewed! (impossible)", e);
}
}
if (LOG.isTraceEnabled()) {
ZooTrace.logTraceMessage(LOG,
ZooTrace.SESSION_TRACE_MASK,
"Session 0x" + Long.toHexString(id)
+ " is valid: "+ valid);
}
dos.writeBoolean(valid);
qp.setData(bos.toByteArray());
learnerHandler.queuePacket(qp);
}
代码示例来源:origin: konsoletyper/teavm
private void writeMethod(OutputStream stream, MethodHolder method) throws IOException {
DataOutputStream output = new DataOutputStream(stream);
output.writeInt(symbolTable.lookup(method.getDescriptor().toString()));
output.writeByte(method.getLevel().ordinal());
output.writeInt(packModifiers(method.getModifiers()));
writeAnnotations(output, method.getAnnotations());
for (AnnotationContainer parameterAnnotation : method.getParameterAnnotations()) {
writeAnnotations(output, parameterAnnotation);
}
if (method.getAnnotationDefault() != null) {
output.writeBoolean(true);
writeAnnotationValue(output, method.getAnnotationDefault());
} else {
output.writeBoolean(false);
}
if (method.getProgram() != null) {
output.writeBoolean(true);
programIO.write(method.getProgram(), output);
} else {
output.writeBoolean(false);
}
}
代码示例来源:origin: marytts/marytts
dos.writeBoolean(useJampackInAnalysis);
dos.writeBoolean(isSilentAnalysis);
dos.writeInt(harmonicModel);
dos.writeInt(noiseModel);
dos.writeBoolean(useHarmonicAmplitudesDirectly);
dos.writeFloat(regularizedCepstrumLambdaHarmonic);
dos.writeBoolean(useWeightingInRegularizedCepstrumEstimationHarmonic);
dos.writeInt(harmonicPartCepstrumOrderPreMel);
dos.writeInt(harmonicPartCepstrumOrder);
dos.writeBoolean(computeNoisePartLpOrderFromSamplingRate);
dos.writeInt(noisePartLpOrder);
dos.writeFloat(preemphasisCoefNoise);
dos.writeBoolean(hpfBeforeNoiseAnalysis);
dos.writeBoolean(decimateNoiseWaveform);
dos.writeBoolean(overlapNoiseWaveformModel);
dos.writeBoolean(useNoiseAmplitudesDirectly);
dos.writeFloat(regularizedCepstrumEstimationLambdaNoise);
dos.writeBoolean(useWeightingInRegularizedCesptrumEstimationNoise);
dos.writeInt(noisePartCepstrumOderPre);
dos.writeInt(noisePartCepstrumOrder);
dos.writeBoolean(usePosteriorMelWarpingNoise);
代码示例来源:origin: ebean-orm/ebean
@Override
public void writeBinary(BinaryWriteContext out) throws IOException {
DataOutputStream os = out.start(TYPE_TABLEIUD);
os.writeUTF(table);
os.writeBoolean(insert);
os.writeBoolean(update);
os.writeBoolean(delete);
}
代码示例来源:origin: google/guava
private void initializeData(DataOutputStream out) throws IOException {
/* Write out various test values NORMALLY */
out.write(new byte[] {-100, 100});
out.writeBoolean(true);
out.writeBoolean(false);
out.writeByte(100);
out.writeByte(-100);
out.writeByte((byte) 200);
out.writeChar('a');
out.writeShort((short) -30000);
out.writeShort((short) 50000);
out.writeInt(0xCAFEBABE);
out.writeLong(0xDEADBEEFCAFEBABEL);
out.writeUTF("Herby Derby");
out.writeFloat(Float.intBitsToFloat(0xCAFEBABE));
out.writeDouble(Double.longBitsToDouble(0xDEADBEEFCAFEBABEL));
}
内容来源于网络,如有侵权,请联系作者删除!