本文整理匯總了Java中java.io.DataOutputStream.writeChar方法的典型用法代碼示例。如果您正苦於以下問題:Java DataOutputStream.writeChar方法的具體用法?Java DataOutputStream.writeChar怎麽用?Java DataOutputStream.writeChar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.io.DataOutputStream
的用法示例。
在下文中一共展示了DataOutputStream.writeChar方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: persistPaths
import java.io.DataOutputStream; //導入方法依賴的package包/類
private void persistPaths (File repository, List<HgLogMessageChangedPath> changePaths, String revision) {
Storage storage = StorageManager.getInstance().getStorage(repository.getAbsolutePath());
ByteArrayOutputStream content = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(content);
try {
dos.writeUTF(PERSISTED_DATA_VERSION);
dos.writeInt(changePaths.size());
for (HgLogMessageChangedPath path : changePaths) {
dos.writeUTF(path.getPath());
dos.writeChar(path.getAction());
dos.writeUTF(path.getCopySrcPath() == null ? "" : path.getCopySrcPath());
}
dos.close();
LOG.log(Level.FINE, "persisting changePaths to disk cache for {0}", new Object[] { revision }); //NOI18N
storage.setRevisionInfo(revision, new ByteArrayInputStream(content.toByteArray()));
} catch (IOException ex) {
LOG.log(Level.INFO, "Cannot persist data", ex); //NOI18N
}
}
示例2: initializeData
import java.io.DataOutputStream; //導入方法依賴的package包/類
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));
}
示例3: serializeHeader
import java.io.DataOutputStream; //導入方法依賴的package包/類
/**
* Serialize a trie2 Header and Index onto an OutputStream. This is
* common code used for both the Trie2_16 and Trie2_32 serialize functions.
* @param dos the stream to which the serialized Trie2 data will be written.
* @return the number of bytes written.
*/
protected int serializeHeader(DataOutputStream dos) throws IOException {
// Write the header. It is already set and ready to use, having been
// created when the Trie2 was unserialized or when it was frozen.
int bytesWritten = 0;
dos.writeInt(header.signature);
dos.writeShort(header.options);
dos.writeShort(header.indexLength);
dos.writeShort(header.shiftedDataLength);
dos.writeShort(header.index2NullOffset);
dos.writeShort(header.dataNullOffset);
dos.writeShort(header.shiftedHighStart);
bytesWritten += 16;
// Write the index
int i;
for (i=0; i< header.indexLength; i++) {
dos.writeChar(index[i]);
}
bytesWritten += header.indexLength;
return bytesWritten;
}
示例4: save
import java.io.DataOutputStream; //導入方法依賴的package包/類
@Override
public void save(DataOutputStream out) throws Exception {
out.writeInt(o.length);
for (char c : o) {
out.writeChar(c);
}
out.writeInt(w.length);
for (double v : w) {
out.writeDouble(v);
}
}
示例5: walkToSave
import java.io.DataOutputStream; //導入方法依賴的package包/類
protected void walkToSave(DataOutputStream out) throws IOException {
out.writeChar(c);
out.writeInt(status.ordinal());
int childSize = 0;
if (child != null) childSize = child.length;
out.writeInt(childSize);
if (child == null) return;
for (BaseNode node : child) {
node.walkToSave(out);
}
}
示例6: writeMessage
import java.io.DataOutputStream; //導入方法依賴的package包/類
@Override
protected void writeMessage(OutputStream out) throws IOException {
DataOutputStream dos = new DataOutputStream(out);
dos.writeUTF(protocolId);
dos.write(protocolVersion);
int flags = cleanSession ? 2 : 0;
flags |= hasWill ? 0x04 : 0;
flags |= willQoS == null ? 0 : willQoS.getValue() << 3;
flags |= retainWill ? 0x20 : 0;
flags |= hasPassword ? 0x40 : 0;
flags |= hasUsername ? 0x80 : 0;
dos.write((byte) flags);
dos.writeChar(keepAlive);
dos.writeUTF(clientId);
if (hasWill) {
dos.writeUTF(willTopic);
dos.writeUTF(will);
}
if (hasUsername) {
dos.writeUTF(username);
}
if (hasPassword) {
dos.writeUTF(password);
}
dos.flush();
}
示例7: serialize
import java.io.DataOutputStream; //導入方法依賴的package包/類
/**
* Serialize a Trie2_16 onto an OutputStream.
*
* A Trie2 can be serialized multiple times.
* The serialized data is compatible with ICU4C UTrie2 serialization.
* Trie2 serialization is unrelated to Java object serialization.
*
* @param os the stream to which the serialized Trie2 data will be written.
* @return the number of bytes written.
* @throw IOException on an error writing to the OutputStream.
*/
public int serialize(OutputStream os) throws IOException {
DataOutputStream dos = new DataOutputStream(os);
int bytesWritten = 0;
bytesWritten += serializeHeader(dos);
for (int i=0; i<dataLength; i++) {
dos.writeChar(index[data16+i]);
}
bytesWritten += dataLength*2;
return bytesWritten;
}
示例8: saveDat
import java.io.DataOutputStream; //導入方法依賴的package包/類
static boolean saveDat(String path, AhoCorasickDoubleArrayTrie<String> trie, Set<Map.Entry<String, String>> entrySet)
{
if (trie.size() != entrySet.size())
{
logger.warning("鍵值對不匹配");
return false;
}
try
{
DataOutputStream out = new DataOutputStream(IOUtil.newOutputStream(path + Predefine.BIN_EXT));
out.writeInt(entrySet.size());
for (Map.Entry<String, String> entry : entrySet)
{
char[] charArray = entry.getValue().toCharArray();
out.writeInt(charArray.length);
for (char c : charArray)
{
out.writeChar(c);
}
}
trie.save(out);
out.close();
}
catch (Exception e)
{
logger.warning("緩存值dat" + path + "失敗");
return false;
}
return true;
}
示例9: save
import java.io.DataOutputStream; //導入方法依賴的package包/類
@Override
public void save(DataOutputStream out) throws Exception
{
out.writeInt(o.length);
for (char c : o)
{
out.writeChar(c);
}
out.writeInt(w.length);
for (double v : w)
{
out.writeDouble(v);
}
}
示例10: saveDat
import java.io.DataOutputStream; //導入方法依賴的package包/類
boolean saveDat(String path, TreeMap<String, Attribute> map)
{
Collection<Attribute> attributeList = map.values();
// 緩存值文件
try
{
DataOutputStream out = new DataOutputStream(IOUtil.newOutputStream(path + Predefine.BIN_EXT));
out.writeInt(attributeList.size());
for (Attribute attribute : attributeList)
{
out.writeInt(attribute.p.length);
for (int i = 0; i < attribute.p.length; ++i)
{
char[] charArray = attribute.dependencyRelation[i].toCharArray();
out.writeInt(charArray.length);
for (char c : charArray)
{
out.writeChar(c);
}
out.writeFloat(attribute.p[i]);
}
}
if (!trie.save(out)) return false;
out.close();
}
catch (Exception e)
{
logger.warning("保存失敗" + e);
return false;
}
return true;
}
示例11: save
import java.io.DataOutputStream; //導入方法依賴的package包/類
@Override
public void save(DataOutputStream out) throws Exception
{
out.writeChar(letter);
out.writeByte(isAcceptNode ? 1 : 0);
out.writeInt(transitionSetBeginIndex);
out.writeInt(transitionSetSize);
}
示例12: walkToSave
import java.io.DataOutputStream; //導入方法依賴的package包/類
protected void walkToSave(DataOutputStream out) throws IOException
{
out.writeChar(c);
out.writeInt(status.ordinal());
int childSize = 0;
if (child != null) childSize = child.length;
out.writeInt(childSize);
if (child == null) return;
for (BaseNode node : child)
{
node.walkToSave(out);
}
}
示例13: testWriteAndRead
import java.io.DataOutputStream; //導入方法依賴的package包/類
public void testWriteAndRead() throws Exception
{
DataOutputStream out = new DataOutputStream(new FileOutputStream(DATA_OUT_DAT));
out.writeChar('H');
out.writeChar('e');
out.writeChar('l');
out.writeChar('l');
out.writeChar('o');
out.close();
ByteArray byteArray = ByteArray.createByteArray(DATA_OUT_DAT);
while (byteArray.hasMore())
{
System.out.println(byteArray.nextChar());
}
}
示例14: save
import java.io.DataOutputStream; //導入方法依賴的package包/類
public void save(DataOutputStream dos, int stored) throws IOException {
dos.writeInt(type);
switch (type) {
case TYPE_BYTE:
for (int i = 0; i < stored; i++) {
dos.writeByte(byteArray[i]);
}
break;
case TYPE_SHORT:
for (int i = 0; i < stored; i++) {
dos.writeShort(shortArray[i]);
}
break;
case TYPE_INT:
for (int i = 0; i < stored; i++) {
dos.writeInt(intArray[i]);
}
break;
case TYPE_CHAR:
for (int i = 0; i < stored; i++) {
dos.writeChar(charArray[i]);
}
break;
case TYPE_BIT:
int ints = bitsToInts(stored);
for (int i = 0; i < ints; i++) {
dos.writeInt(bitArray[i]);
}
break;
}
}
示例15: writeString
import java.io.DataOutputStream; //導入方法依賴的package包/類
private static void writeString(DataOutputStream dos, String str) throws UnsupportedEncodingException, IOException {
byte[] data = str.getBytes("UTF8");
dos.writeChar(data.length);
dos.write(data);
}