本文整理了Java中java.io.ObjectOutputStream.writeString()
方法的一些代码示例,展示了ObjectOutputStream.writeString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObjectOutputStream.writeString()
方法的具体详情如下:
包路径:java.io.ObjectOutputStream
类名称:ObjectOutputStream
方法名:writeString
[英]Writes given string to stream, using standard or long UTF format depending on string length.
[中]根据字符串长度,使用标准或长UTF格式将给定字符串写入流。
代码示例来源:origin: stackoverflow.com
out.writeString(nvp.getName());
out.writeString(nvp.getValue());
代码示例来源:origin: stackoverflow.com
public class MyClass {
private static final int CUR_VERSION = 5;
private String _value;
private void readObject(ObjectInputStream in) {
// first value is always the serial version:
int dataVersion = in.readInt();
if(dataVersion == CUR_VERSION) {
// _value is a String
_value = in.readString();
} else {
// in older versions, _value was an int
_value = String.valueOf(in.readInt());
}
}
private void writeObject(ObjectOutputStream out) {
// always write version first
out.writeInt(CUR_VERSION);
out.writeString(_value);
}
}
代码示例来源:origin: jtulach/bck2brwsr
/**
* Writes string without allowing it to be replaced in stream. Used by
* ObjectStreamClass to write class descriptor type strings.
*/
void writeTypeString(String str) throws IOException {
int handle;
if (str == null) {
writeNull();
} else if ((handle = handles.lookup(str)) != -1) {
writeHandle(handle);
} else {
writeString(str, false);
}
}
代码示例来源:origin: org.apidesign.bck2brwsr/emul
/**
* Writes string without allowing it to be replaced in stream. Used by
* ObjectStreamClass to write class descriptor type strings.
*/
void writeTypeString(String str) throws IOException {
int handle;
if (str == null) {
writeNull();
} else if ((handle = handles.lookup(str)) != -1) {
writeHandle(handle);
} else {
writeString(str, false);
}
}
代码示例来源:origin: jtulach/bck2brwsr
/**
* Writes given enum constant to stream.
*/
private void writeEnum(Enum en,
ObjectStreamClass desc,
boolean unshared)
throws IOException
{
bout.writeByte(TC_ENUM);
ObjectStreamClass sdesc = desc.getSuperDesc();
writeClassDesc((sdesc.forClass() == Enum.class) ? desc : sdesc, false);
handles.assign(unshared ? null : en);
writeString(en.name(), false);
}
代码示例来源:origin: org.apidesign.bck2brwsr/emul
/**
* Writes given enum constant to stream.
*/
private void writeEnum(Enum en,
ObjectStreamClass desc,
boolean unshared)
throws IOException
{
bout.writeByte(TC_ENUM);
ObjectStreamClass sdesc = desc.getSuperDesc();
writeClassDesc((sdesc.forClass() == Enum.class) ? desc : sdesc, false);
handles.assign(unshared ? null : en);
writeString(en.name(), false);
}
代码示例来源:origin: jtulach/bck2brwsr
writeString((String) obj, unshared);
} else if (cl.isArray()) {
writeArray(obj, desc, unshared);
代码示例来源:origin: org.apidesign.bck2brwsr/emul
writeString((String) obj, unshared);
} else if (cl.isArray()) {
writeArray(obj, desc, unshared);
内容来源于网络,如有侵权,请联系作者删除!