当前位置: 首页>>代码示例>>Java>>正文


Java BufferedReader.markSupported方法代码示例

本文整理汇总了Java中java.io.BufferedReader.markSupported方法的典型用法代码示例。如果您正苦于以下问题:Java BufferedReader.markSupported方法的具体用法?Java BufferedReader.markSupported怎么用?Java BufferedReader.markSupported使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.BufferedReader的用法示例。


在下文中一共展示了BufferedReader.markSupported方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readHeader

import java.io.BufferedReader; //导入方法依赖的package包/类
/**
 * reads the header comment lines. Must have eventSize and chunkSizeBytes
 * set for backwards compatiblity for files without headers to short address
 * sizes.
 */
protected void readHeader(FileInputStream fileInputStream) throws IOException {

    if (fileInputStream == null) {
        throw new IOException("null fileInputStream");
    }
    if (fileInputStream.available() == 0) {
        throw new IOException("empty file (0 bytes available)");
    }

    BufferedReader bufferedHeaderReader = new BufferedReader(new InputStreamReader(fileInputStream));
    headerOffset = 0; // start from 0
    if (!bufferedHeaderReader.markSupported()) {
        throw new IOException("no mark supported while reading file header, is this a normal file?");
    }
    String s;
    // System.out.println("File header:");
    while ((s = readHeaderLine(bufferedHeaderReader)) != null) {
        header.add(s);
        parseFileFormatVersion(s);
    }
    // we don't map yet until we know eventSize
    StringBuilder sb = new StringBuilder();
    sb.append("File header (clipped to " + NUM_HEADER_LINES_TO_PRINT + " lines: \n");
    int nLines = 0;
    for (String str : header) {
        sb.append(str);
        sb.append(lineSeparator); // "\n");
        if (nLines++ > NUM_HEADER_LINES_TO_PRINT) {
            break;
        }
    }
    log.info(sb.toString());
    bufferedHeaderReader = null; // mark for GC, but don't close or underlying channel breaks!
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:40,代码来源:AEFileInputStream.java

示例2: logResponse

import java.io.BufferedReader; //导入方法依赖的package包/类
private void logResponse(ClientHttpResponse response,
        final BufferedReader bufferedReader) throws IOException {
    log("============================response begin==========================================");
    log("status code: {}", response.getStatusCode());
    log("status text: {}", response.getStatusText());
    if (bufferedReader.markSupported()) {
        writeBody(bufferedReader);
    }
    bufferedReader.close();
    log("=======================response end=================================================");
}
 
开发者ID:zg2pro,项目名称:spring-rest-basis,代码行数:12,代码来源:LoggingRequestInterceptor.java


注:本文中的java.io.BufferedReader.markSupported方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。