本文整理了Java中ucar.unidata.io.RandomAccessFile.length
方法的一些代码示例,展示了RandomAccessFile.length
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RandomAccessFile.length
方法的具体详情如下:
包路径:ucar.unidata.io.RandomAccessFile
类名称:RandomAccessFile
方法名:length
[英]Get the length of the file. The data in the buffer (which may not have been written the disk yet) is taken into account.
[中]获取文件的长度。缓冲区中的数据(可能尚未写入磁盘)将被考虑在内。
代码示例来源:origin: edu.ucar/netcdf
SeqIter(StructureDataRegexp.Vinfo vinfo) throws IOException {
this.vinfo = vinfo;
totalBytes = (int) vinfo.rafile.length();
vinfo.rafile.seek(0);
}
代码示例来源:origin: edu.ucar/netcdf
public static Cinrad2Record factory(RandomAccessFile din, int record) throws IOException {
long offset = record * RADAR_DATA_SIZE + FILE_HEADER_SIZE;
if (offset >= din.length())
return null;
else
return new Cinrad2Record(din, record);
}
int getUInt( byte[] b, int num )
代码示例来源:origin: Unidata/thredds
SeqIter(StructureDataRegexp.Vinfo vinfo) throws IOException {
this.vinfo = vinfo;
totalBytes = (int) vinfo.rafile.length();
vinfo.rafile.seek(0);
}
代码示例来源:origin: edu.ucar/netcdf
/**
* Create a new one
*
* @throws IOException problem reading the file
*/
SeqIter() throws IOException {
totalBytes = (int) raf.length();
raf.seek(0);
}
代码示例来源:origin: edu.ucar/netcdf
public static Level2Record factory(RandomAccessFile din, int record, long message_offset31) throws IOException {
long offset = record * RADAR_DATA_SIZE + FILE_HEADER_SIZE + message_offset31;
if (offset >= din.length())
return null;
else
return new Level2Record(din, record, message_offset31);
}
代码示例来源:origin: edu.ucar/cdm
/**
* Create a new one
*
* @throws IOException problem reading the file
*/
SeqIter() throws IOException {
totalBytes = (int) raf.length();
raf.seek(0);
}
代码示例来源:origin: edu.ucar/cdm
SeqIter(StructureDataRegexp.Vinfo vinfo) throws IOException {
this.vinfo = vinfo;
totalBytes = (int) vinfo.rafile.length();
vinfo.rafile.seek(0);
}
代码示例来源:origin: Unidata/thredds
SeqIter(Vinfo vinfo) throws IOException {
this.vinfo = vinfo;
totalBytes = (int) raf.length();
vinfo.raf.seek(0);
}
代码示例来源:origin: Unidata/thredds
public static Cinrad2Record factory(RandomAccessFile din, int record) throws IOException {
long offset = (long)record * RADAR_DATA_SIZE + FILE_HEADER_SIZE;
if (offset >= din.length())
return null;
else
return new Cinrad2Record(din, record);
}
代码示例来源:origin: Unidata/thredds
StationSeqIter(StructureDataRegexp.Vinfo vinfo) throws IOException {
this.vinfo = vinfo;
totalBytes = (int) vinfo.rafile.length();
vinfo.rafile.seek(0);
}
代码示例来源:origin: edu.ucar/netcdf
@Override
public String getDetailInfo() {
if (raf == null) return "";
try {
Formatter fout = new Formatter();
double size = raf.length() / (1000.0 * 1000.0);
fout.format(" raf = %s%n", raf.getLocation());
fout.format(" size= %d (%s Mb)%n%n", raf.length(), Format.dfrac(size, 3));
return fout.toString();
} catch (IOException e) {
return e.getMessage();
}
}
代码示例来源:origin: edu.ucar/cdm
@Override
public String getDetailInfo() {
if (raf == null) return "";
try {
Formatter fout = new Formatter();
double size = raf.length() / (1000.0 * 1000.0);
fout.format(" raf = %s%n", raf.getLocation());
fout.format(" size= %d (%s Mb)%n%n", raf.length(), Format.dfrac(size, 3));
return fout.toString();
} catch (IOException e) {
return e.getMessage();
}
}
代码示例来源:origin: edu.ucar/netcdf
SeqIter(Vinfo vinfo) throws IOException {
this.vinfo = vinfo;
totalBytes = (int) raf.length();
vinfo.raf.seek(0);
}
代码示例来源:origin: edu.ucar/netcdf
StationSeqIter(StructureDataRegexp.Vinfo vinfo) throws IOException {
this.vinfo = vinfo;
totalBytes = (int) vinfo.rafile.length();
vinfo.rafile.seek(0);
}
代码示例来源:origin: Unidata/thredds
private void init() {
if (!exists) return;
try {
if (dataRaf != null)
this.timeSeriesRaf = dataRaf; // single station case - data file already open
else
this.timeSeriesRaf = RandomAccessFile.acquire(file.getPath());
totalBytes = timeSeriesRaf.length();
timeSeriesRaf.seek(0);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
代码示例来源: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: Unidata/thredds
public byte[] getData(int offset) throws IOException {
int readLen = (int) raf.length();
byte[] b = new byte[readLen];
int pos = 0;
raf.seek(pos);
raf.readFully(b);
return b;
}
代码示例来源:origin: edu.ucar/netcdf
public byte[] getData(int offset) throws Exception {
int readLen = (int) raf.length();
byte[] b = new byte[readLen];
int pos = 0;
raf.seek(pos);
int rc = raf.read(b);
return b;
}
代码示例来源:origin: Unidata/thredds
private Array readData(ucar.nc2.Variable v2, long dataPos, List<Range> ranges,
int[] levels) throws IOException, InvalidRangeException {
// Get to the proper offset and read in the data
raf.seek(dataPos);
int data_size = (int) (raf.length() - dataPos);
byte[] data = new byte[data_size];
raf.readFully(data);
// Turn it into an array
Array array = makeArray(data, levels, v2.getShape());
return array.sectionNoReduce(ranges);
}
代码示例来源:origin: edu.ucar/grib
static public boolean isValidFile(RandomAccessFile raf) throws IOException {
raf.seek(0);
if (!raf.searchForward(matcher, 8000)) return false; // must find "GRIB" in first 8k
raf.skipBytes(4);
// Read Section 0 Indicator Section to get Edition number
Grib2IndicatorSection is = new Grib2IndicatorSection(raf); // section 0
if (is.getGribEdition() != 1 && is.getGribEdition() != 2)
return false;
if (is.getGribLength() > raf.length())
return false;
return true;
}
内容来源于网络,如有侵权,请联系作者删除!