java.io.RandomAccessFile.readChar()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(166)

本文整理了Java中java.io.RandomAccessFile.readChar方法的一些代码示例,展示了RandomAccessFile.readChar的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RandomAccessFile.readChar方法的具体详情如下:
包路径:java.io.RandomAccessFile
类名称:RandomAccessFile
方法名:readChar

RandomAccessFile.readChar介绍

[英]Reads a big-endian 16-bit character from the current position in this file. Blocks until two bytes have been read, the end of the file is reached or an exception is thrown.
[中]从文件中的当前位置读取一个大端16位字符。块,直到读取两个字节、到达文件结尾或引发异常为止。

代码示例

代码示例来源:origin: stackoverflow.com

try{
   String fileName = "c:/myraffile.txt";
   File file = new File(fileName);
   RandomAccessFile raf = new RandomAccessFile(file, "rw");
   raf.readChar();
   raf.seek(0);
} catch (FileNotFoundException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
} catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
}

代码示例来源:origin: atomix/atomix

@Override
public char readChar(int offset) {
 checkRead(offset, CHARACTER);
 try {
  seekToOffset(offset);
  return randomAccessFile.readChar();
 } catch (IOException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: apache/activemq

@Override
public char readChar() throws IOException {
  try {
    return getRaf().readChar();
  } catch (IOException ioe) {
    handleException();
    throw ioe;
  }
}

代码示例来源:origin: i2p/i2p.i2p

public char readChar()				throws IOException { return delegate.readChar(); }
public double readDouble()			throws IOException { return delegate.readDouble(); }

代码示例来源:origin: stackoverflow.com

File target = new File("/path/to/file");
RandomAccessFile file = new RandomAccessFile(target,"rwd");
file.seek(target.length()-1); // Set the pointer to the end of the file
char c = file.readChar();
if(c == '|') // Change the pipe character to whatever your sentinel character is
{
   file.setLength(target.length()-1); // Strip off the last _byte_, not the last character
}

代码示例来源:origin: org.jetbrains.intellij.deps/commons-vfs2

@Override
public char readChar() throws IOException
{
  return raf.readChar();
}

代码示例来源:origin: org.checkerframework/checker-qual7

/**
 * Reads an unsigned char from the RandomAccessFile f. This method is a wrapper around {@link
 * java.io.RandomAccessFile#readChar() readChar()}, but assumes the output should be interpreted
 * as unsigned.
 */
@SuppressWarnings("signedness")
public static @Unsigned char readUnsignedChar(RandomAccessFile f) throws IOException {
  return f.readChar();
}

代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger

/**
 * Reads an unsigned char from the RandomAccessFile f. This method is a wrapper around {@link
 * java.io.RandomAccessFile#readChar() readChar()}, but assumes the output should be interpreted
 * as unsigned.
 */
@SuppressWarnings("signedness")
public static @Unsigned char readUnsignedChar(RandomAccessFile f) throws IOException {
  return f.readChar();
}

代码示例来源:origin: stackoverflow.com

File f = new File("outputfile");
RandomAccessFile raf = new RandomAccessFile(f, "rw");

char ch = raf.readChar(); // establish the connection
raf.seek(f.length()); // go to the end of the file
raf.writeUTF("some string"); // write something
raf.close(); // close it.

代码示例来源:origin: org.onosproject/onlab-thirdparty

@Override
public char readChar(long offset) {
 checkRead(offset, CHARACTER);
 try {
  seekToOffset(offset);
  return randomAccessFile.readChar();
 } catch (IOException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: io.atomix.catalyst/catalyst-buffer

@Override
public char readChar(long offset) {
 checkRead(offset, CHARACTER);
 try {
  seekToOffset(offset);
  return randomAccessFile.readChar();
 } catch (IOException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: io.atomix/catalyst-buffer

@Override
public char readChar(long offset) {
 checkRead(offset, CHARACTER);
 try {
  seekToOffset(offset);
  return randomAccessFile.readChar();
 } catch (IOException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: io.atomix/atomix-storage

@Override
public char readChar(int offset) {
 checkRead(offset, CHARACTER);
 try {
  seekToOffset(offset);
  return randomAccessFile.readChar();
 } catch (IOException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: atomix/catalyst

@Override
public char readChar(long offset) {
 checkRead(offset, CHARACTER);
 try {
  seekToOffset(offset);
  return randomAccessFile.readChar();
 } catch (IOException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: io.atomix/atomix-buffer

@Override
public char readChar(int offset) {
 checkRead(offset, CHARACTER);
 try {
  seekToOffset(offset);
  return randomAccessFile.readChar();
 } catch (IOException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: stackoverflow.com

RandomAccessFile f = new RandomAccessFile("theRandomeAccessFile", "rw");
 f.writeInt(1);
 f.writeDouble(2.34);
 f.writeUTF("SomeString");
 f.writeChar('C');
 f.seek(0);
 System.err.println(f.readInt());
 System.err.println(f.readDouble());
 System.err.println(f.readUTF());
 System.err.println(f.readChar());

代码示例来源:origin: org.apache.activemq/activemq-all

@Override
public char readChar() throws IOException {
  try {
    return getRaf().readChar();
  } catch (IOException ioe) {
    handleException();
    throw ioe;
  }
}

代码示例来源:origin: org.apache.activemq/activemq-osgi

@Override
public char readChar() throws IOException {
  try {
    return getRaf().readChar();
  } catch (IOException ioe) {
    handleException();
    throw ioe;
  }
}

代码示例来源:origin: org.apache.activemq/activemq-kahadb-store

@Override
public char readChar() throws IOException {
  try {
    return getRaf().readChar();
  } catch (IOException ioe) {
    handleException();
    throw ioe;
  }
}

代码示例来源:origin: octo-online/reactive-audit

@Test(expected = FileReactiveAuditException.class)
public void readChar()
    throws IOException
{
  ReactiveAudit.off.commit();
  try (RandomAccessFile rw = newRandomAccessFile())
  {
    TestTools.strict.commit();
    rw.readChar();
  }
}

相关文章