org.apache.commons.io.IOUtils.toBufferedReader()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(138)

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

IOUtils.toBufferedReader介绍

[英]Returns the given reader if it is a BufferedReader, otherwise creates a toBufferedReader for the given reader.
[中]如果给定读取器是BufferedReader,则返回该读取器,否则为给定读取器创建toBufferedReader。

代码示例

代码示例来源:origin: commons-io/commons-io

/**
 * Gets the contents of a <code>Reader</code> as a list of Strings,
 * one entry per line.
 * <p>
 * This method buffers the input internally, so there is no need to use a
 * <code>BufferedReader</code>.
 *
 * @param input the <code>Reader</code> to read from, not null
 * @return the list of Strings, never null
 * @throws NullPointerException if the input is null
 * @throws IOException          if an I/O error occurs
 * @since 1.1
 */
public static List<String> readLines(final Reader input) throws IOException {
  final BufferedReader reader = toBufferedReader(input);
  final List<String> list = new ArrayList<>();
  String line = reader.readLine();
  while (line != null) {
    list.add(line);
    line = reader.readLine();
  }
  return list;
}

代码示例来源:origin: commons-io/commons-io

input1 = toBufferedReader(input1);
input2 = toBufferedReader(input2);

代码示例来源:origin: commons-io/commons-io

/**
 * Compares the contents of two Readers to determine if they are equal or
 * not, ignoring EOL characters.
 * <p>
 * This method buffers the input internally using
 * <code>BufferedReader</code> if they are not already buffered.
 *
 * @param input1 the first reader
 * @param input2 the second reader
 * @return true if the content of the readers are equal (ignoring EOL differences),  false otherwise
 * @throws NullPointerException if either input is null
 * @throws IOException          if an I/O error occurs
 * @since 2.2
 */
public static boolean contentEqualsIgnoreEOL(final Reader input1, final Reader input2)
    throws IOException {
  if (input1 == input2) {
    return true;
  }
  final BufferedReader br1 = toBufferedReader(input1);
  final BufferedReader br2 = toBufferedReader(input2);
  String line1 = br1.readLine();
  String line2 = br2.readLine();
  while (line1 != null && line2 != null && line1.equals(line2)) {
    line1 = br1.readLine();
    line2 = br2.readLine();
  }
  return line1 == null ? line2 == null ? true : false : line1.equals(line2);
}

代码示例来源:origin: org.wisdom-framework/wisdom-engine

/**
 * Get the reader to read the request.
 *
 * @return The reader
 */
@Override
public BufferedReader reader() throws IOException {
  if (raw != null) {
    return IOUtils.toBufferedReader(new StringReader(raw));
  }
  return null;
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch

@CheckForNull
 public static String getServerVersion() {
  InputStream is = BatchUtils.class.getResourceAsStream("/sq-version.txt");
  if (is == null) {
   LOG.warn("Failed to get SQ version");
   return null;
  }
  try (BufferedReader br = IOUtils.toBufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
   return br.readLine();
  } catch (IOException e) {
   LOG.warn("Failed to get SQ version", e);
   return null;
  }
 }
}

代码示例来源:origin: Nextdoor/bender

/**
 * Compare the contents of two Readers to determine if they are equal or
 * not, ignoring EOL characters.
 * <p>
 * This method buffers the input internally using
 * <code>BufferedReader</code> if they are not already buffered.
 *
 * @param input1  the first reader
 * @param input2  the second reader
 * @return true if the content of the readers are equal (ignoring EOL differences),  false otherwise
 * @throws NullPointerException if either input is null
 * @throws IOException if an I/O error occurs
 * @since 2.2
 */
public static boolean contentEqualsIgnoreEOL(Reader input1, Reader input2)
    throws IOException {
  BufferedReader br1 = toBufferedReader(input1);
  BufferedReader br2 = toBufferedReader(input2);
  String line1 = br1.readLine();
  String line2 = br2.readLine();
  while (line1 != null && line2 != null && line1.equals(line2)) {
    line1 = br1.readLine();
    line2 = br2.readLine();
  }
  return line1 == null ? line2 == null ? true : false : line1.equals(line2);
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

input1 = toBufferedReader(input1);
input2 = toBufferedReader(input2);

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

/**
 * Compare the contents of two Readers to determine if they are equal or
 * not, ignoring EOL characters.
 * <p>
 * This method buffers the input internally using
 * <code>BufferedReader</code> if they are not already buffered.
 *
 * @param input1  the first reader
 * @param input2  the second reader
 * @return true if the content of the readers are equal (ignoring EOL differences),  false otherwise
 * @throws NullPointerException if either input is null
 * @throws IOException if an I/O error occurs
 * @since 2.2
 */
public static boolean contentEqualsIgnoreEOL(Reader input1, Reader input2)
    throws IOException {
  BufferedReader br1 = toBufferedReader(input1);
  BufferedReader br2 = toBufferedReader(input2);
  String line1 = br1.readLine();
  String line2 = br2.readLine();
  while (line1 != null && line2 != null && line1.equals(line2)) {
    line1 = br1.readLine();
    line2 = br2.readLine();
  }
  return line1 == null ? line2 == null ? true : false : line1.equals(line2);
}

代码示例来源:origin: org.wisdom-framework/wisdom-vertx-engine

/**
 * Gets the reader to read the request.
 *
 * @return The reader
 */
@Override
public BufferedReader reader() throws IOException {
  byte[] raw = request.getRawBody();
  if (raw != null) {
    return IOUtils.toBufferedReader(new InputStreamReader(new ByteArrayInputStream(raw)));
  }
  return null;
}

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

throws IOException {
input1 = toBufferedReader(input1);
input2 = toBufferedReader(input2);

代码示例来源:origin: Nextdoor/bender

throws IOException {
input1 = toBufferedReader(input1);
input2 = toBufferedReader(input2);

代码示例来源:origin: Nextdoor/bender

/**
 * Get the contents of a <code>Reader</code> as a list of Strings,
 * one entry per line.
 * <p>
 * This method buffers the input internally, so there is no need to use a
 * <code>BufferedReader</code>.
 *
 * @param input  the <code>Reader</code> to read from, not null
 * @return the list of Strings, never null
 * @throws NullPointerException if the input is null
 * @throws IOException if an I/O error occurs
 * @since 1.1
 */
public static List<String> readLines(Reader input) throws IOException {
  BufferedReader reader = toBufferedReader(input);
  List<String> list = new ArrayList<String>();
  String line = reader.readLine();
  while (line != null) {
    list.add(line);
    line = reader.readLine();
  }
  return list;
}

代码示例来源:origin: io.github.stephenc.docker/docker-client-shaded

/**
 * Gets the contents of a <code>Reader</code> as a list of Strings,
 * one entry per line.
 * <p>
 * This method buffers the input internally, so there is no need to use a
 * <code>BufferedReader</code>.
 *
 * @param input the <code>Reader</code> to read from, not null
 * @return the list of Strings, never null
 * @throws NullPointerException if the input is null
 * @throws IOException          if an I/O error occurs
 * @since 1.1
 */
public static List<String> readLines(final Reader input) throws IOException {
  final BufferedReader reader = toBufferedReader(input);
  final List<String> list = new ArrayList<String>();
  String line = reader.readLine();
  while (line != null) {
    list.add(line);
    line = reader.readLine();
  }
  return list;
}

代码示例来源:origin: io.github.stephenc.docker/docker-client-shaded

/**
 * Compares the contents of two Readers to determine if they are equal or
 * not, ignoring EOL characters.
 * <p>
 * This method buffers the input internally using
 * <code>BufferedReader</code> if they are not already buffered.
 *
 * @param input1 the first reader
 * @param input2 the second reader
 * @return true if the content of the readers are equal (ignoring EOL differences),  false otherwise
 * @throws NullPointerException if either input is null
 * @throws IOException          if an I/O error occurs
 * @since 2.2
 */
public static boolean contentEqualsIgnoreEOL(final Reader input1, final Reader input2)
    throws IOException {
  if (input1 == input2) {
    return true;
  }
  final BufferedReader br1 = toBufferedReader(input1);
  final BufferedReader br2 = toBufferedReader(input2);
  String line1 = br1.readLine();
  String line2 = br2.readLine();
  while (line1 != null && line2 != null && line1.equals(line2)) {
    line1 = br1.readLine();
    line2 = br2.readLine();
  }
  return line1 == null ? line2 == null ? true : false : line1.equals(line2);
}

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

/**
 * Get the contents of a <code>Reader</code> as a list of Strings,
 * one entry per line.
 * <p>
 * This method buffers the input internally, so there is no need to use a
 * <code>BufferedReader</code>.
 *
 * @param input  the <code>Reader</code> to read from, not null
 * @return the list of Strings, never null
 * @throws NullPointerException if the input is null
 * @throws IOException if an I/O error occurs
 * @since 1.1
 */
public static List<String> readLines(Reader input) throws IOException {
  BufferedReader reader = toBufferedReader(input);
  List<String> list = new ArrayList<String>();
  String line = reader.readLine();
  while (line != null) {
    list.add(line);
    line = reader.readLine();
  }
  return list;
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Gets the contents of a <code>Reader</code> as a list of Strings,
 * one entry per line.
 * <p>
 * This method buffers the input internally, so there is no need to use a
 * <code>BufferedReader</code>.
 *
 * @param input the <code>Reader</code> to read from, not null
 * @return the list of Strings, never null
 * @throws NullPointerException if the input is null
 * @throws IOException          if an I/O error occurs
 * @since 1.1
 */
public static List<String> readLines(final Reader input) throws IOException {
  final BufferedReader reader = toBufferedReader(input);
  final List<String> list = new ArrayList<>();
  String line = reader.readLine();
  while (line != null) {
    list.add(line);
    line = reader.readLine();
  }
  return list;
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Compares the contents of two Readers to determine if they are equal or
 * not, ignoring EOL characters.
 * <p>
 * This method buffers the input internally using
 * <code>BufferedReader</code> if they are not already buffered.
 *
 * @param input1 the first reader
 * @param input2 the second reader
 * @return true if the content of the readers are equal (ignoring EOL differences),  false otherwise
 * @throws NullPointerException if either input is null
 * @throws IOException          if an I/O error occurs
 * @since 2.2
 */
public static boolean contentEqualsIgnoreEOL(final Reader input1, final Reader input2)
    throws IOException {
  if (input1 == input2) {
    return true;
  }
  final BufferedReader br1 = toBufferedReader(input1);
  final BufferedReader br2 = toBufferedReader(input2);
  String line1 = br1.readLine();
  String line2 = br2.readLine();
  while (line1 != null && line2 != null && line1.equals(line2)) {
    line1 = br1.readLine();
    line2 = br2.readLine();
  }
  return line1 == null ? line2 == null ? true : false : line1.equals(line2);
}

代码示例来源:origin: org.phenotips/medsavant-client-api

private boolean isCorrectVCF(XWikiAttachment attachment, String eid, XWikiContext context)
    throws XWikiException, IOException
  {
    BufferedReader in =
      IOUtils.toBufferedReader(new InputStreamReader(attachment.getContentInputStream(context),
        XWiki.DEFAULT_ENCODING));
    String line;
    while ((line = in.readLine()) != null) {
      if (line.startsWith("##")) {
        // Still in the meta, go on
        continue;
      } else if (!line.startsWith("#CHROM")) {
        // Actual data, we're past the meta but didn't encounter the header, strange...
        // Malformed file, abandon
        break;
      }
      String[] fields = line.split("\t");
      if (fields.length != 10 || !StringUtils.equals(eid, fields[9])) {
        // Wrong sample ID or more than one sample, bail out
        break;
      }
      return true;
    }
    return false;
  }
}

代码示例来源:origin: com.rexsl/rexsl

try {
  source = new StreamSource(
    IOUtils.toBufferedReader(
      new InputStreamReader(
        IOUtils.toInputStream(

代码示例来源:origin: Nepxion/Thunder

BufferedReader bufferedReader = IOUtils.toBufferedReader(inputStreamReader);
String line = bufferedReader.readLine();
while (line != null) {

相关文章