當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。