本文整理汇总了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=================================================");
}