java.io.DataOutput#writeChar ( )源码实例Demo

下面列出了java.io.DataOutput#writeChar ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: systemds   文件: ColGroupDDC2.java
@Override
public void write(DataOutput out) throws IOException {
	int numCols = getNumCols();
	int numVals = getNumValues();
	out.writeInt(_numRows);
	out.writeInt(numCols);
	out.writeInt(numVals);

	// write col indices
	for(int i = 0; i < _colIndexes.length; i++)
		out.writeInt(_colIndexes[i]);

	// write distinct values
	for(int i = 0; i < _values.length; i++)
		out.writeDouble(_values[i]);

	// write data
	for(int i = 0; i < _numRows; i++)
		out.writeChar(_data[i]);
}
 
源代码2 项目: systemds   文件: ColGroupDDC2.java
@Override
public void write(DataOutput out) throws IOException {
	int numCols = getNumCols();
	int numVals = getNumValues();
	out.writeInt(_numRows);
	out.writeInt(numCols);
	out.writeInt(numVals);

	// write col indices
	for(int i = 0; i < _colIndexes.length; i++)
		out.writeInt(_colIndexes[i]);

	// write distinct values
	double[] values = getValues();
	for(int i = 0; i < values.length; i++)
		out.writeDouble(values[i]);

	// write data
	for(int i = 0; i < _numRows; i++)
		out.writeChar(_data[i]);
}
 
源代码3 项目: lucene-solr   文件: Row.java
/**
 * Write the contents of this Row to the given output stream.
 * 
 * @param os the output stream
 * @exception IOException if an I/O error occurs
 */
public void store(DataOutput os) throws IOException {
  os.writeInt(cells.size());
  Iterator<Character> i = cells.keySet().iterator();
  for (; i.hasNext();) {
    Character c = i.next();
    Cell e = at(c);
    if (e.cmd < 0 && e.ref < 0) {
      continue;
    }
    
    os.writeChar(c.charValue());
    os.writeInt(e.cmd);
    os.writeInt(e.cnt);
    os.writeInt(e.ref);
    os.writeInt(e.skip);
  }
}
 
@Override
public void write(DataOutput out) throws IOException {
  String whole = writeStream();
  int chunkSize = 1 << 14;
  int chunks = whole.length() / chunkSize;
  if (whole.length() % chunkSize != 0) {
    chunks += 1;
  }

  out.writeChar(FIRST_MAGIC_BYTES);
  out.write(new byte[]{NEXT_MAGIC_BYTE});

  out.writeInt(chunks);
  for (int c = 0; c < chunks; c++) {
    String chunk = whole.substring(c * chunkSize, Math.min((c + 1) * chunkSize, whole.length()));
    out.writeUTF(chunk);
  }
}
 
源代码5 项目: hadoop   文件: SummationWritable.java
/** Write ArithmeticProgression to DataOutput */
private static void write(ArithmeticProgression ap, DataOutput out
    ) throws IOException {
  out.writeChar(ap.symbol);
  out.writeLong(ap.value);
  out.writeLong(ap.delta);
  out.writeLong(ap.limit);
}
 
源代码6 项目: btree4j   文件: IOUtils.java
public static void writeString(@Nullable final String s, final DataOutput out)
        throws IOException {
    if (s == null) {
        out.writeInt(-1);
        return;
    }
    final int len = s.length();
    out.writeInt(len);
    for (int i = 0; i < len; i++) {
        int v = s.charAt(i);
        out.writeChar(v);
    }
}
 
源代码7 项目: gemfirexd-oss   文件: MapLiteSerializer.java
public static void writeCharacter(Character value, DataOutput output) throws IOException
{
	if (value == null) {
		output.writeChar(0);
	} else {
		output.writeChar(value);
	}
}
 
源代码8 项目: gemfirexd-oss   文件: DataSerializer.java
/**
 * Writes a primitive  <code>char</code> to a
 * <code>DataOutput</code>.
 *
 * @throws IOException
 *         A problem occurs while writing to <code>out</code>
 *
 * @see DataOutput#writeChar
 * @since 5.1
 */
public static void writePrimitiveChar(char value, DataOutput out)
  throws IOException {

  InternalDataSerializer.checkOut(out);

  if (DEBUG) {
    InternalDataSerializer.logger.info( LocalizedStrings.DEBUG, "Writing Char " + value);
  }

  out.writeChar(value);
}
 
源代码9 项目: big-c   文件: SummationWritable.java
/** Write ArithmeticProgression to DataOutput */
private static void write(ArithmeticProgression ap, DataOutput out
    ) throws IOException {
  out.writeChar(ap.symbol);
  out.writeLong(ap.value);
  out.writeLong(ap.delta);
  out.writeLong(ap.limit);
}
 
源代码10 项目: incubator-hivemall   文件: IOUtils.java
public static void writeString(@Nullable final String s, final DataOutput out)
        throws IOException {
    if (s == null) {
        out.writeInt(-1);
        return;
    }
    final int len = s.length();
    out.writeInt(len);
    for (int i = 0; i < len; i++) {
        int v = s.charAt(i);
        out.writeChar(v);
    }
}
 
源代码11 项目: gemfirexd-oss   文件: MapLiteSerializer.java
public static void writeCharacter(Character value, DataOutput output) throws IOException
{
	if (value == null) {
		output.writeChar(0);
	} else {
		output.writeChar(value);
	}
}
 
源代码12 项目: gemfirexd-oss   文件: DataSerializer.java
/**
 * Writes an instance of <code>Character</code> to a
 * <code>DataOutput</code>.
 *
 * @throws IOException
 *         A problem occurs while writing to <code>out</code>
 * @throws NullPointerException if value is null.
 *
 * @see #readCharacter
 */
public static void writeCharacter(Character value, DataOutput out)
  throws IOException {

  InternalDataSerializer.checkOut(out);

  if (DEBUG) {
    InternalDataSerializer.logger.info( LocalizedStrings.DEBUG, "Writing Character " + value);
  }

  out.writeChar(value.charValue());
}
 
源代码13 项目: gemfirexd-oss   文件: DataSerializer.java
/**
 * Writes a primitive  <code>char</code> to a
 * <code>DataOutput</code>.
 *
 * @throws IOException
 *         A problem occurs while writing to <code>out</code>
 *
 * @see DataOutput#writeChar
 * @since 5.1
 */
public static void writePrimitiveChar(char value, DataOutput out)
  throws IOException {

  InternalDataSerializer.checkOut(out);

  if (DEBUG) {
    InternalDataSerializer.logger.info( LocalizedStrings.DEBUG, "Writing Char " + value);
  }

  out.writeChar(value);
}
 
源代码14 项目: Hadoop-BAM   文件: VariantContextCodec.java
private static void encodeAttrVal(final DataOutput out, final Object v)
	throws IOException
{
	if (v instanceof Integer) {
		out.writeByte(AttrType.INT.toByte());
		out.writeInt ((Integer)v);
	} else if (v instanceof Float) {
		out.writeByte (AttrType.FLOAT.toByte());
		out.writeFloat((Float)v);
	} else if (v instanceof Double) {
		out.writeByte  (AttrType.DOUBLE.toByte());
		out.writeDouble((Double)v);
	} else if (v instanceof Boolean) {
		out.writeByte   (AttrType.BOOL.toByte());
		out.writeBoolean((Boolean)v);
	} else if (v instanceof Character) {
		out.writeByte(AttrType.CHAR.toByte());
		out.writeChar((Character)v);

	} else if (v instanceof List) {
		encodeAttrVal(out, ((List)v).toArray());

	} else if (v != null && v.getClass().isArray()) {
		out.writeByte(AttrType.ARRAY.toByte());
		final int length = Array.getLength(v);
		out.writeInt(length);
		for (int i = 0; i < length; ++i)
			encodeAttrVal(out, Array.get(v, i));

	} else {
		out.writeByte(AttrType.STRING.toByte());
		if (v == null)
			out.writeInt(0);
		else {
			final byte[] b = v.toString().getBytes("UTF-8");
			out.writeInt(b.length);
			out.write   (b);
		}
	}
}
 
源代码15 项目: stratosphere   文件: CharValue.java
@Override
public void write(DataOutput out) throws IOException {
	out.writeChar(this.value);
}
 
源代码16 项目: stratosphere   文件: CharType.java
@Override
public void write(DataOutput out) throws IOException {
	out.writeChar(this.value);
}
 
源代码17 项目: util   文件: CharSerializer.java
@Override
public void write(final Character val, final DataOutput out) throws IOException {
    out.writeChar(val);
}
 
源代码18 项目: gemfirexd-oss   文件: DeltaObject.java
protected void _toDelta(DataOutput out) throws IOException {
   Log.getLogWriter().info("In DeltaObject.toDelta, for " + this + "\n" + "with DataOutput " + out);
   DeltaObserver.addToDeltaKey(extra);

   // for validation later, encode with a toDelta id number
   long toDeltaIdNumber = DeltaPropagationBB.getBB().getSharedCounters().incrementAndRead(DeltaPropagationBB.toDeltaIdNumber);
   out.writeLong(toDeltaIdNumber);
   Log.getLogWriter().info("Wrote toDeltaIdNumber " + toDeltaIdNumber);

   out.writeBoolean(aPrimitiveLongChanged);
   if (aPrimitiveLongChanged) {
      out.writeLong(aPrimitiveLong);
      Log.getLogWriter().info("Wrote changed field aPrimitiveLong " + aPrimitiveLong);
   }
   out.writeBoolean(aPrimitiveIntChanged);
   if (aPrimitiveIntChanged) {
      out.writeInt(aPrimitiveInt);
      Log.getLogWriter().info("Wrote changed field aPrimitiveInt " + aPrimitiveInt);
   }
   out.writeBoolean(aPrimitiveShortChanged);
   if (aPrimitiveShortChanged) {
      out.writeShort(aPrimitiveShort);
      Log.getLogWriter().info("Wrote changed field aPrimitiveShort " + aPrimitiveShort);
   }
   out.writeBoolean(aPrimitiveFloatChanged);
   if (aPrimitiveFloatChanged) {
      out.writeFloat(aPrimitiveFloat);
      Log.getLogWriter().info("Wrote changed field aPrimitiveFloat " + aPrimitiveFloat);
   }
   out.writeBoolean(aPrimitiveDoubleChanged);
   if (aPrimitiveDoubleChanged) {
      out.writeDouble(aPrimitiveDouble);
      Log.getLogWriter().info("Wrote changed field aPrimitiveDouble " + aPrimitiveDouble);
   }
   out.writeBoolean(aPrimitiveByteChanged);
   if (aPrimitiveByteChanged) {
      out.writeByte(aPrimitiveByte);
      Log.getLogWriter().info("Wrote changed field aPrimitiveByte " + aPrimitiveByte);
   }
   out.writeBoolean(aPrimitiveCharChanged);
   if (aPrimitiveCharChanged) {
      out.writeChar(aPrimitiveChar);
      Log.getLogWriter().info("Wrote changed field aPrimitiveChar " + aPrimitiveChar);
   }
   out.writeBoolean(aPrimitiveBooleanChanged);
   if (aPrimitiveBooleanChanged) {
      out.writeBoolean(aPrimitiveBoolean);
      Log.getLogWriter().info("Wrote changed field aPrimitiveBoolean " + aPrimitiveBoolean);
   }
   out.writeBoolean(aByteArrayChanged);
   if (aByteArrayChanged) {
      out.writeInt(aByteArray.length);
      out.write(aByteArray);
      Log.getLogWriter().info("Wrote changed field aByteArray of length " + aByteArray.length);
   }
   out.writeBoolean(aStringChanged);
   if (aStringChanged) {
      out.writeInt(aString.length());
      out.writeBytes(aString);
      Log.getLogWriter().info("Wrote changed field aString " + aString);
   }
   out.writeInt(END_SIGNAL.length());
   out.writeBytes(END_SIGNAL);
   Log.getLogWriter().info("Wrote end signal: " + END_SIGNAL);
   Log.getLogWriter().info("Done writing in DeltaObject.toDelta for " + this);
}
 
源代码19 项目: big-c   文件: ArrayPrimitiveWritable.java
private void writeCharArray(DataOutput out) throws IOException {
  char[] v = (char[]) value;
  for (int i = 0; i < length; i++)
    out.writeChar(v[i]);
}
 
源代码20 项目: ignite   文件: HadoopDataStreamSelfTest.java
/**
 * @param out Data output.
 * @throws IOException On error.
 */
private void write(DataOutput out) throws IOException {
    out.writeBoolean(false);
    out.writeBoolean(true);
    out.writeBoolean(false);
    out.write(17);
    out.write(121);
    out.write(0xfafa);
    out.writeByte(17);
    out.writeByte(121);
    out.writeByte(0xfafa);
    out.writeChar('z');
    out.writeChar('o');
    out.writeChar('r');
    out.writeShort(100);
    out.writeShort(Short.MIN_VALUE);
    out.writeShort(Short.MAX_VALUE);
    out.writeShort(65535);
    out.writeShort(65536); // 0
    out.writeInt(Integer.MAX_VALUE);
    out.writeInt(Integer.MIN_VALUE);
    out.writeInt(-1);
    out.writeInt(0);
    out.writeInt(1);
    out.writeFloat(0.33f);
    out.writeFloat(0.5f);
    out.writeFloat(-0.7f);
    out.writeFloat(Float.MAX_VALUE);
    out.writeFloat(Float.MIN_VALUE);
    out.writeFloat(Float.MIN_NORMAL);
    out.writeFloat(Float.POSITIVE_INFINITY);
    out.writeFloat(Float.NEGATIVE_INFINITY);
    out.writeFloat(Float.NaN);
    out.writeDouble(-12312312.3333333336666779);
    out.writeDouble(123123.234);
    out.writeDouble(Double.MAX_VALUE);
    out.writeDouble(Double.MIN_VALUE);
    out.writeDouble(Double.MIN_NORMAL);
    out.writeDouble(Double.NEGATIVE_INFINITY);
    out.writeDouble(Double.POSITIVE_INFINITY);
    out.writeDouble(Double.NaN);
    out.writeLong(Long.MAX_VALUE);
    out.writeLong(Long.MIN_VALUE);
    out.writeLong(0);
    out.writeLong(-1L);
    out.write(new byte[] {1, 2, 3});
    out.write(new byte[] {0, 1, 2, 3}, 1, 2);
    out.writeUTF("mom washes rum");
}