本文整理了Java中ucar.unidata.io.RandomAccessFile.readString
方法的一些代码示例,展示了RandomAccessFile.readString
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RandomAccessFile.readString
方法的具体详情如下:
包路径:ucar.unidata.io.RandomAccessFile
类名称:RandomAccessFile
方法名:readString
[英]Read a String of known length.
[中]读一个已知长度的字符串。
代码示例来源:origin: edu.ucar/cdm
/**
* Read a String of known length.
*
* @param size number of bytes
* @return String result
* @throws java.io.IOException on io error
*/
private String readStringFixedLength(int size) throws IOException {
return raf.readString(size);
}
代码示例来源:origin: Unidata/thredds
/**
* Read a String of known length.
*
* @param size number of bytes
* @return String result
* @throws java.io.IOException on io error
*/
private String readStringFixedLength(int size) throws IOException {
return raf.readString(size);
}
代码示例来源:origin: Unidata/thredds
void read() throws IOException {
datemod = raf.readString(14);
if (debug1) {
log.debug(" MessageLastModifiedOld={}", datemod);
}
}
代码示例来源:origin: edu.ucar/cdm
void read() throws IOException {
datemod = raf.readString(14);
if (debug1) debugOut.println(" MessageLastModifiedOld=" + datemod);
}
代码示例来源:origin: edu.ucar/cdm
private boolean endRecord(RandomAccessFile raf) throws IOException {
if (showSkip) System.out.print(" endRecord start at " + raf.getFilePointer());
int skipped = 0;
String endRecord = raf.readString(10); // new String(raf.readBytes(10), CDM.utf8Charset);
while (endRecord.equals("END RECORD")) {
endRecord = raf.readString(10); // new String(raf.readBytes(10));
skipped++;
}
if (showSkip) System.out.println(" last 10 chars= " + endRecord + " skipped= " + skipped);
return true;
}
代码示例来源:origin: Unidata/thredds
private boolean endRecord(RandomAccessFile raf) throws IOException {
if (showSkip) System.out.print(" endRecord start at " + raf.getFilePointer());
int skipped = 0;
String endRecord = raf.readString(10); // new String(raf.readBytes(10), CDM.utf8Charset);
while (endRecord.equals("END RECORD")) {
endRecord = raf.readString(10); // new String(raf.readBytes(10));
skipped++;
}
if (showSkip) System.out.println(" last 10 chars= " + endRecord + " skipped= " + skipped);
return true;
}
代码示例来源:origin: edu.ucar/cdm
public boolean isValidFile( RandomAccessFile raf) throws IOException {
try {
raf.seek(0);
String test = raf.readString(8);
return test.equals( Level2VolumeScan.ARCHIVE2) || test.equals( Level2VolumeScan.AR2V0001) ||
test.equals( Level2VolumeScan.AR2V0003)|| test.equals( Level2VolumeScan.AR2V0004) ||
test.equals( Level2VolumeScan.AR2V0002) || test.equals( Level2VolumeScan.AR2V0006) ||
test.equals( Level2VolumeScan.AR2V0007);
} catch (IOException ioe) {
return false;
}
}
代码示例来源:origin: Unidata/thredds
public boolean isValidFile( RandomAccessFile raf) throws IOException {
try {
raf.seek(0);
String test = raf.readString(8);
return test.equals( Level2VolumeScan.ARCHIVE2) || test.equals( Level2VolumeScan.AR2V0001) ||
test.equals( Level2VolumeScan.AR2V0003)|| test.equals( Level2VolumeScan.AR2V0004) ||
test.equals( Level2VolumeScan.AR2V0002) || test.equals( Level2VolumeScan.AR2V0006) ||
test.equals( Level2VolumeScan.AR2V0007);
} catch (IOException ioe) {
return false;
}
}
代码示例来源:origin: Unidata/thredds
/**
* Check if this is a valid file for this IOServiceProvider.
* You must make this method thread safe, ie dont keep any state.
*
* @param raf RandomAccessFile
* @return true if valid.
* @throws IOException if read error
*/
public boolean isValidFile(RandomAccessFile raf) throws IOException {
raf.seek(0);
String test = raf.readString(MAGIC.length());
return test.equals(MAGIC);
}
代码示例来源:origin: edu.ucar/cdm
/**
* Check if this is a valid file for this IOServiceProvider.
* You must make this method thread safe, ie dont keep any state.
*
* @param raf RandomAccessFile
* @return true if valid.
* @throws IOException if read error
*/
public boolean isValidFile(RandomAccessFile raf) throws IOException {
raf.seek(0);
String test = raf.readString(MAGIC.length());
return test.equals(MAGIC);
}
代码示例来源:origin: edu.ucar/cdm
/**
* Check if this is a valid file for this IOServiceProvider.
*
* @param raf RandomAccessFile
* @return true if valid.
* @throws IOException if read error
*/
public boolean isValidFile(RandomAccessFile raf) throws IOException {
raf.seek(0);
int n = MAGIC.length();
if (raf.length() < n) {
return false;
}
String got = raf.readString(n);
return (pMAGIC.matcher(got).find() || pMAGIC_OLD.matcher(got).find());
}
代码示例来源:origin: edu.ucar/cdm
static public boolean isValidFile(ucar.unidata.io.RandomAccessFile raf) throws IOException {
long filePos = 0;
long size = raf.length();
// search forward for the header
while ((filePos < size) && (filePos < maxHeaderPos)) {
raf.seek(filePos);
String magic = raf.readString(8);
if (magic.equals(hdf5magic))
return true;
filePos = (filePos == 0) ? 512 : 2 * filePos;
}
return false;
}
代码示例来源:origin: edu.ucar/cdm
static boolean isValidFile(ucar.unidata.io.RandomAccessFile raf) throws IOException {
long pos = 0;
long size = raf.length();
// search forward for the header
while ((pos < size) && (pos < maxHeaderPos)) {
raf.seek(pos);
String magic = raf.readString(4);
if (magic.equals(shead))
return true;
pos = (pos == 0) ? 512 : 2 * pos;
}
return false;
}
代码示例来源:origin: Unidata/thredds
static boolean validatePIB(ucar.unidata.io.RandomAccessFile raf) throws IOException {
int pos = 0;
raf.seek(pos);
// gini header process
String pib = raf.readString(GINI_PIB_LEN + GINI_HED_LEN);
return findWMOHeader(pib) != 0;
}
代码示例来源:origin: edu.ucar/netcdf
private String getDataBlockStringValue(RandomAccessFile raf, short offset, int skip, int size) throws IOException {
long off = offset + message_offset + MESSAGE_HEADER_SIZE;
raf.seek(off);
raf.skipBytes(skip);
return raf.readString(size);
}
代码示例来源:origin: edu.ucar/cdm
private String getDataBlockStringValue(RandomAccessFile raf, short offset, int skip, int size) throws IOException {
long off = offset + message_offset + MESSAGE_HEADER_SIZE;
raf.seek(off);
raf.skipBytes(skip);
return raf.readString(size);
}
代码示例来源:origin: Unidata/thredds
private String getDataBlockStringValue(RandomAccessFile raf, short offset, int skip, int size) throws IOException {
long off = offset + message_offset + MESSAGE_HEADER_SIZE;
raf.seek(off);
raf.skipBytes(skip);
return raf.readString(size);
}
代码示例来源:origin: edu.ucar/cdm
/**
* Check if this is a valid file for this IOServiceProvider.
*
* @param raf RandomAccessFile
* @return true if valid.
*/
public boolean isValidFile(RandomAccessFile raf) throws IOException {
try {
raf.order(RandomAccessFile.BIG_ENDIAN);
raf.seek(0);
raf.skipBytes(4);
String test = raf.readString(40);
return test.equals(EMISSIONS) || test.equals(AVERAGE) || test.equals(AIRQUALITY) || test.equals(INSTANT);
} catch (IOException ioe) {
return false;
}
}
代码示例来源:origin: edu.ucar/cdm
private boolean endFile(RandomAccessFile raf) throws IOException {
if (showSkip) System.out.println(" endFile start at " + raf.getFilePointer());
String endRecord = raf.readString(10); // new String(raf.readBytes(10));
while (endRecord.equals("ENDOF FILE")) {
endRecord = raf.readString(10); // new String(raf.readBytes(10));
}
try {
while (raf.read() != (int) 'X') ; //find where X's start
while (raf.read() == (int) 'X') ; //skip X's till you run out
raf.skipBytes(-1); // go back one
readHeader(raf);
return true;
} catch (EOFException e) {
return false;
}
}
代码示例来源:origin: Unidata/thredds
/**
* Read a zero terminated String. Leave file positioned after zero terminator byte.
*
* @param raf from this file
* @return String (dont include zero terminator)
* @throws java.io.IOException on io error
*/
private String readString(RandomAccessFile raf) throws IOException {
long filePos = raf.getFilePointer();
int count = 0;
while (raf.readByte() != 0) count++;
raf.seek(filePos);
String result = raf.readString(count);
raf.readByte(); // skip the zero byte! nn
return result;
}
内容来源于网络,如有侵权,请联系作者删除!