ucar.unidata.io.RandomAccessFile.readLine()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(130)

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

RandomAccessFile.readLine介绍

[英]Reads the next line of text from this file. This method successively reads bytes from the file, starting at the current file pointer, until it reaches a line terminator or the end of the file. Each byte is converted into a character by taking the byte's value for the lower eight bits of the character and setting the high eight bits of the character to zero. This method does not, therefore, support the full Unicode character set.

A line of text is terminated by a carriage-return character ('\r'), a newline character ('\n'), a carriage-return character immediately followed by a newline character, or the end of the file. Line-terminating characters are discarded and are not included as part of the string returned.

This method blocks until a newline character is read, a carriage return and the byte following it are read (to see if it is a newline), the end of the file is reached, or an exception is thrown.
[中]从该文件中读取下一行文本。此方法从当前文件指针开始,连续读取文件中的字节,直到到达行终止符或文件结尾。每个字节都被转换成一个字符,方法是取字符低八位的字节值,并将字符高八位设置为零。因此,此方法不支持完整的Unicode字符集。
文本行以回车符('\r')、换行符('\n')、紧跟换行符的回车符或文件结尾终止。行尾字符将被丢弃,不作为返回字符串的一部分包含。
此方法会一直阻塞,直到读取换行符、读取回车符及其后的字节(以查看它是否为换行符)、到达文件结尾或引发异常为止。

代码示例

代码示例来源:origin: Unidata/thredds

private boolean isValidFile(RandomAccessFile raf, Pattern p) throws IOException {
 raf.seek(0);
 String line;
 while (true) {
  line = raf.readLine();
  if (line == null) break;
  if (line.trim().length() == 0) continue;
  Matcher matcher = p.matcher(line);
  return matcher.matches();
 }
 return false;
}

代码示例来源:origin: edu.ucar/netcdf

private boolean isValidFile(RandomAccessFile raf, Pattern p) throws IOException {
 raf.seek(0);
 String line;
 while (true) {
  line = raf.readLine();
  if (line == null) break;
  if (line.trim().length() == 0) continue;
  Matcher matcher = p.matcher(line);
  return matcher.matches();
 }
 return false;
}

代码示例来源:origin: edu.ucar/cdm

private boolean isValidFile(RandomAccessFile raf, Pattern p) throws IOException {
 raf.seek(0);
 String line;
 while (true) {
  line = raf.readLine();
  if (line == null) break;
  if (line.trim().length() == 0) continue;
  Matcher matcher = p.matcher(line);
  return matcher.matches();
 }
 return false;
}

代码示例来源:origin: edu.ucar/netcdf

private boolean isValidFile(RandomAccessFile raf, Pattern p) throws IOException {
 raf.seek(0);
 String line;
 while (true) {
  line = raf.readLine();
  if (line == null) break;
  if (line.startsWith("#")) continue;
  if (line.trim().length() == 0) continue;
  Matcher matcher = p.matcher(line);
  return matcher.matches();
 }
 return false;
}

代码示例来源:origin: edu.ucar/cdm

private boolean isValidFile(RandomAccessFile raf, Pattern p) throws IOException {
 raf.seek(0);
 String line;
 while (true) {
  line = raf.readLine();
  if (line == null) break;
  if (line.startsWith("#")) continue;
  if (line.trim().length() == 0) continue;
  Matcher matcher = p.matcher(line);
  return matcher.matches();
 }
 return false;
}

代码示例来源:origin: Unidata/thredds

private boolean isValidFile(RandomAccessFile raf, Pattern p) throws IOException {
 raf.seek(0);
 String line;
 while (true) {
  line = raf.readLine();
  if (line == null) break;
  if (line.startsWith("#")) continue;
  if (line.trim().length() == 0) continue;
  Matcher matcher = p.matcher(line);
  return matcher.matches();
 }
 return false;
}

代码示例来源:origin: edu.ucar/netcdf

@Override
public StructureData next() throws IOException {
 String line;
 while (true) {
  line = raf.readLine();
  if (line == null) return null;
  if (line.startsWith("#")) continue;
  if (line.trim().length() == 0) continue;
  break;
 }
 //System.out.printf("%s%n", line);
 countRead++;
 return new StructureDataAscii(sm, line);
}

代码示例来源:origin: edu.ucar/cdm

@Override
public StructureData next() throws IOException {
 String line;
 while (true) {
  line = raf.readLine();
  if (line == null) return null;
  if (line.startsWith("#")) continue;
  if (line.trim().length() == 0) continue;
  break;
 }
 //System.out.printf("%s%n", line);
 countRead++;
 return new StructureDataAscii(sm, line);
}

代码示例来源:origin: Unidata/thredds

private StructureData reallyNext() throws IOException {
 Matcher matcher;
 while (true) {
  String line = vinfo.rafile.readLine();
  if (line == null) return null;
  if (line.startsWith("#")) continue;
  if (line.trim().length() == 0) continue;
  //System.out.printf("line %s%n", line);
  matcher = vinfo.p.matcher(line);
  if (matcher.matches())
   break;
  System.out.printf("FAIL %s%n", line);
 }
 recno++;
 return new StationData(vinfo.sm, matcher);
}

代码示例来源:origin: Unidata/thredds

@Override
public StructureData next() throws IOException {
 String line;
 while (true) {
  line = raf.readLine();
  if (line == null) return null;
  if (line.startsWith("#")) continue;
  if (line.trim().length() == 0) continue;
  break;
 }
 //System.out.printf("%s%n", line);
 countRead++;
 return new StructureDataAscii(sm, line);
}

代码示例来源:origin: edu.ucar/netcdf

private StructureData reallyNext() throws IOException {
 Matcher matcher;
 while (true) {
  String line = vinfo.rafile.readLine();
  if (line == null) return null;
  if (line.startsWith("#")) continue;
  if (line.trim().length() == 0) continue;
  //System.out.printf("line %s%n", line);
  matcher = vinfo.p.matcher(line);
  if (matcher.matches())
   break;
  System.out.printf("FAIL %s%n", line);
 }
 recno++;
 return new StationData(vinfo.sm, matcher);
}

代码示例来源:origin: edu.ucar/netcdf

@Override
public StructureData next() throws IOException {
 Matcher matcher;
 String line;
 while (true) {
  line = timeSeriesRaf.readLine();
  if (line == null) return null;  // only on EOF
  if (line.trim().length() == 0) continue;
  matcher = seriesVinfo.p.matcher(line);
  if (matcher.matches())
   break;
  System.out.printf("FAIL TimeSeriesIter <%s>%n", line);
 }
 countRead++;
 return new TimeSeriesData(matcher);
}

代码示例来源:origin: edu.ucar/cdm

private StructureData reallyNext() throws IOException {
 Matcher matcher;
 while (true) {
  String line = vinfo.rafile.readLine();
  if (line == null) return null;
  if (line.startsWith("#")) continue;
  if (line.trim().length() == 0) continue;
  //System.out.printf("line %s%n", line);
  matcher = vinfo.p.matcher(line);
  if (matcher.matches())
   break;
  System.out.printf("FAIL %s%n", line);
 }
 recno++;
 return new StationData(vinfo.sm, matcher);
}

代码示例来源:origin: Unidata/thredds

private StructureData reallyNext() throws IOException {
 String line;
 while (true) {
  line = vinfo.raf.readLine();
  if (line == null) return null;
  if (line.startsWith("#")) continue;
  if (line.trim().length() == 0) continue;
  break;
 }
 //System.out.printf("%s%n", line);
 bytesRead = vinfo.raf.getFilePointer();
 recno++;
 return new StructureDataAsciiGhcnm(vinfo.sm, line);
}

代码示例来源:origin: edu.ucar/cdm

static private void readDataRegexp(String filename) throws IOException {
 int balony = 0;
 long start = System.currentTimeMillis();
 System.out.printf("regexp %s%n", filename);
 try (RandomAccessFile raf = new RandomAccessFile(filename, "r")) {
  String line;
  while (true) {
   line = raf.readLine();
   if (line == null) break;
   if (line.startsWith("#")) continue;
   if (line.trim().length() == 0) continue;
   balony += parseLine(line);
  }
 }
 long took = System.currentTimeMillis() - start;
 System.out.printf("DONE %d == %d msecs%n", balony, took);
}

代码示例来源:origin: edu.ucar/cdm

private StructureData reallyNext() throws IOException {
 String line;
 while (true) {
  line = vinfo.raf.readLine();
  if (line == null) return null;
  if (line.startsWith("#")) continue;
  if (line.trim().length() == 0) continue;
  break;
 }
 //System.out.printf("%s%n", line);
 bytesRead = vinfo.raf.getFilePointer();
 recno++;
 return new StructureDataAsciiGhcnm(vinfo.sm, line);
}

代码示例来源:origin: Unidata/thredds

private StructureData reallyNext() throws IOException {
 Matcher matcher;
 while (true) {
  String line = vinfo.rafile.readLine();
  if (line == null) return null;
  if (line.startsWith("#")) continue;
  if (line.trim().length() == 0) continue;
  matcher = vinfo.p.matcher(line);
  if (matcher.matches())
   break;
  System.out.printf("FAIL %s%n", line);
 }
 //System.out.printf("%s%n", line);
 bytesRead = vinfo.rafile.getFilePointer();
 recno++;
 return new StructureDataRegexpGhcnm(vinfo.sm, matcher);
}

代码示例来源:origin: edu.ucar/netcdf

static private void readDataRegexp(String filename) throws IOException {
 int balony = 0;
 long start = System.currentTimeMillis();
 System.out.printf("regexp %s%n", filename);
 RandomAccessFile raf = new RandomAccessFile(filename, "r");
 String line;
 while (true) {
  line = raf.readLine();
  if (line == null) break;
  if (line.startsWith("#")) continue;
  if (line.trim().length() == 0) continue;
  balony += parseLine(line);
 }
 long took = System.currentTimeMillis() - start;
 System.out.printf("DONE %d == %d msecs%n", balony, took);
}

代码示例来源:origin: edu.ucar/cdm

private StructureData reallyNext() throws IOException {
 Matcher matcher;
 while (true) {
  String line = vinfo.rafile.readLine();
  if (line == null) return null;
  if (line.startsWith("#")) continue;
  if (line.trim().length() == 0) continue;
  matcher = vinfo.p.matcher(line);
  if (matcher.matches())
   break;
  System.out.printf("FAIL %s%n", line);
 }
 //System.out.printf("%s%n", line);
 bytesRead = vinfo.rafile.getFilePointer();
 recno++;
 return new StructureDataRegexpGhcnm(vinfo.sm, matcher);
}

代码示例来源:origin: edu.ucar/netcdf

private StructureData reallyNext() throws IOException {
 String line;
 while (true) {
  line = vinfo.raf.readLine();
  if (line == null) return null;
  if (line.startsWith("#")) continue;
  if (line.trim().length() == 0) continue;
  break;
 }
 //System.out.printf("%s%n", line);
 bytesRead = vinfo.raf.getFilePointer();
 recno++;
 return new StructureDataAsciiGhcnm(vinfo.sm, line);
}

相关文章