本文整理汇总了Java中java.io.DataInputStream.readChar方法的典型用法代码示例。如果您正苦于以下问题:Java DataInputStream.readChar方法的具体用法?Java DataInputStream.readChar怎么用?Java DataInputStream.readChar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.DataInputStream
的用法示例。
在下文中一共展示了DataInputStream.readChar方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadCachedChangePaths
import java.io.DataInputStream; //导入方法依赖的package包/类
private List<HgLogMessageChangedPath> loadCachedChangePaths (File repository, String revision) {
Storage storage = StorageManager.getInstance().getStorage(repository.getAbsolutePath());
byte[] buff = storage.getRevisionInfo(revision);
if (buff == null) {
return null;
}
List<HgLogMessageChangedPath> changePaths = null;
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(buff));
try {
String version = dis.readUTF();
if (PERSISTED_DATA_VERSION.equals(version)) {
int len = dis.readInt();
changePaths = len == 0 ? null : new ArrayList<HgLogMessageChangedPath>(len); // do not care about empty paths, test for 0
for (int i = 0; i < len; ++i) {
String path = dis.readUTF();
char action = dis.readChar();
String copyPath = dis.readUTF();
changePaths.add(new HgLogMessageChangedPath(path, copyPath.isEmpty() ? null : copyPath, action));
}
}
} catch (IOException ex) {
LOG.log(Level.FINE, "changePaths from disk cache corrupted {0}", new Object[] { revision }); //NOI18N
}
return changePaths;
}
示例2: unserialize
import java.io.DataInputStream; //导入方法依赖的package包/类
/**
* <p>Parses the input stream and stores its trie content into a index and
* data array</p>
* @param inputStream data input stream containing trie data
* @exception IOException thrown when data reading fails
*/
protected final void unserialize(InputStream inputStream)
throws IOException
{
DataInputStream input = new DataInputStream(inputStream);
int indexDataLength = m_dataOffset_ + m_dataLength_;
m_index_ = new char[indexDataLength];
for (int i = 0; i < indexDataLength; i ++) {
m_index_[i] = input.readChar();
}
m_data_ = m_index_;
m_initialValue_ = m_data_[m_dataOffset_];
}
示例3: unserialize
import java.io.DataInputStream; //导入方法依赖的package包/类
/**
* <p>Parses the inputstream and creates the trie index with it.</p>
* <p>This is overwritten by the child classes.
* @param inputStream input stream containing the trie information
* @exception IOException thrown when data reading fails.
*/
protected void unserialize(InputStream inputStream) throws IOException
{
//indexLength is a multiple of 1024 >> INDEX_STAGE_2_SHIFT_
m_index_ = new char[m_dataOffset_];
DataInputStream input = new DataInputStream(inputStream);
for (int i = 0; i < m_dataOffset_; i ++) {
m_index_[i] = input.readChar();
}
}
示例4: read
import java.io.DataInputStream; //导入方法依赖的package包/类
@Override
public void read(DataInputStream input) throws IOException {
value = input.readChar();
}
示例5: GenericWholeArrray
import java.io.DataInputStream; //导入方法依赖的package包/类
public GenericWholeArrray(DataInputStream dis, int stored)
throws IOException {
type = dis.readInt();
switch (type) {
case TYPE_BYTE:
byteArray = new byte[stored];
for (int i = 0; i < stored; i++) {
byteArray[i] = dis.readByte();
}
break;
case TYPE_SHORT:
shortArray = new short[stored];
for (int i = 0; i < stored; i++) {
shortArray[i] = dis.readShort();
}
break;
case TYPE_INT:
intArray = new int[stored];
for (int i = 0; i < stored; i++) {
intArray[i] = dis.readInt();
}
break;
case TYPE_CHAR:
charArray = new char[stored];
for (int i = 0; i < stored; i++) {
charArray[i] = dis.readChar();
}
break;
case TYPE_BIT:
int ints = bitsToInts(stored);
bitArray = new int[ints];
for (int i = 0; i < ints; i++) {
bitArray[i] = dis.readInt();
}
break;
}
}
示例6: readHeader
import java.io.DataInputStream; //导入方法依赖的package包/类
public static final byte[] readHeader(InputStream inputStream,
byte dataFormatIDExpected[],
Authenticate authenticate)
throws IOException
{
DataInputStream input = new DataInputStream(inputStream);
char headersize = input.readChar();
int readcount = 2;
//reading the header format
byte magic1 = input.readByte();
readcount ++;
byte magic2 = input.readByte();
readcount ++;
if (magic1 != MAGIC1 || magic2 != MAGIC2) {
throw new IOException(MAGIC_NUMBER_AUTHENTICATION_FAILED_);
}
input.readChar(); // reading size
readcount += 2;
input.readChar(); // reading reserved word
readcount += 2;
byte bigendian = input.readByte();
readcount ++;
byte charset = input.readByte();
readcount ++;
byte charsize = input.readByte();
readcount ++;
input.readByte(); // reading reserved byte
readcount ++;
byte dataFormatID[] = new byte[4];
input.readFully(dataFormatID);
readcount += 4;
byte dataVersion[] = new byte[4];
input.readFully(dataVersion);
readcount += 4;
byte unicodeVersion[] = new byte[4];
input.readFully(unicodeVersion);
readcount += 4;
if (headersize < readcount) {
throw new IOException("Internal Error: Header size error");
}
input.skipBytes(headersize - readcount);
if (bigendian != BIG_ENDIAN_ || charset != CHAR_SET_
|| charsize != CHAR_SIZE_
|| !Arrays.equals(dataFormatIDExpected, dataFormatID)
|| (authenticate != null
&& !authenticate.isDataVersionAcceptable(dataVersion))) {
throw new IOException(HEADER_AUTHENTICATION_FAILED_);
}
return unicodeVersion;
}