本文整理匯總了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!
}
示例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=================================================");
}