本文整理匯總了Java中java.io.BufferedReader.mark方法的典型用法代碼示例。如果您正苦於以下問題:Java BufferedReader.mark方法的具體用法?Java BufferedReader.mark怎麽用?Java BufferedReader.mark使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.io.BufferedReader
的用法示例。
在下文中一共展示了BufferedReader.mark方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: readLine
import java.io.BufferedReader; //導入方法依賴的package包/類
private String readLine(BufferedReader reader) throws IOException {
resBuffer.setLength(0);
reader.mark(maxJobDelimiterLineLength);
for(String line = reader.readLine();
line != null; line = reader.readLine()) {
if(isEndOfJobLog(line)) {
if(resBuffer.length() == 0)
resBuffer.append(line);
else
reader.reset();
break;
}
if(resBuffer.length() == 0)
resBuffer.append(line);
else if(resBuffer.length() < 32000)
resBuffer.append(line);
if(line.endsWith(" .") || line.endsWith("\" ")) {
break;
}
reader.mark(maxJobDelimiterLineLength);
}
String result = resBuffer.length() == 0 ? null : resBuffer.toString();
resBuffer.setLength(0);
return result;
}
示例2: writeBody
import java.io.BufferedReader; //導入方法依賴的package包/類
private void writeBody(final BufferedReader bufferedReader) throws IOException {
char[] buffer = new char[BUFFER_LENGTH];
StringBuilder inputStringBuilder = new StringBuilder("Response Body : ");
bufferedReader.mark(MARK_LENGTH);
int len = bufferedReader.read(buffer);
String line = new String(buffer);
int curLen = 0;
while (!StringUtils.isEmpty(line) && curLen > -1 && len < MARK_LENGTH) {
inputStringBuilder.append(line);
curLen = bufferedReader.read(buffer);
len += curLen;
line = new String(buffer);
}
if (len == MARK_LENGTH) {
inputStringBuilder.append("...");
}
bufferedReader.reset();
log(inputStringBuilder.toString());
}
示例3: sessionAlreadyImported
import java.io.BufferedReader; //導入方法依賴的package包/類
public static boolean sessionAlreadyImported(File xmlImportFile, File xmlSessionFile) throws IOException {
BufferedReader br1 = new BufferedReader(new FileReader(xmlSessionFile)); //sessionfile
BufferedReader br2 = new BufferedReader(new FileReader(xmlImportFile)); //desktop import
String s1, s2;
s1 = br1.readLine();
s2 = br2.readLine();
s2 = br2.readLine();
br2.mark(2000);;
while(s1 != null) {
while (s1 != null && s2 != null && s1.equals(s2)) {
s1 = br1.readLine();
s2 = br2.readLine();
if (s2 == null) {
br1.close();
br2.close();
return true;
}
}
br2.reset();
s1 = br1.readLine();
}
br1.close();
br2.close();
return false;
}
示例4: parseNumber
import java.io.BufferedReader; //導入方法依賴的package包/類
static JBigInt parseNumber(BufferedReader reader) throws IOException {
skipSpace(reader);
StringBuilder sb = new StringBuilder();
while (true) {
reader.mark(1);
int c = reader.read();
if (c >= '0' && c <= '9' || c == '.' || c == '-') {
sb.append((char)c);
} else {
reader.reset();
break;
}
}
return new JBigInt(sb.toString());
}
示例5: parseNumber
import java.io.BufferedReader; //導入方法依賴的package包/類
static JNumber parseNumber(BufferedReader reader) throws IOException {
skipSpace(reader);
StringBuilder sb = new StringBuilder();
while (true) {
reader.mark(1);
int c = reader.read();
if (c >= '0' && c <= '9' || c == '.' || c == '-') {
sb.append((char)c);
} else {
reader.reset();
break;
}
}
return new JNumber(Double.parseDouble(sb.toString()));
}
示例6: getRootFilesFromContainer
import java.io.BufferedReader; //導入方法依賴的package包/類
private static List<String> getRootFilesFromContainer(BufferedReader containerxml) {
List<String> rootFiles = new ArrayList<>();
try {
containerxml.mark(4);
if ('\ufeff' != containerxml.read()) containerxml.reset(); // not the BOM marker
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(false);
XmlPullParser xpp = factory.newPullParser();
xpp.setInput(containerxml);
int eventType = xpp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG) {
if (xpp.getName().equals("rootfile")) {
for (int i = 0; i < xpp.getAttributeCount(); i++) {
if (xpp.getAttributeName(i).equals("full-path")) {
rootFiles.add(xpp.getAttributeValue(i));
}
}
}
}
eventType = xpp.next();
}
} catch (Exception e) {
Log.e("BMBF", "Error parsing xml " + e, e);
}
return rootFiles;
}
示例7: processToc
import java.io.BufferedReader; //導入方法依賴的package包/類
private static Map<String,?> processToc(BufferedReader tocReader) {
Map<String,Object> bookdat = new LinkedHashMap<>();
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
XPathFactory factory = XPathFactory.newInstance();
DocumentBuilder builder = null;
try {
builder = dfactory.newDocumentBuilder();
tocReader.mark(4);
if ('\ufeff' != tocReader.read()) tocReader.reset(); // not the BOM marker
Document doc = builder.parse(new InputSource(tocReader));
XPath tocPath = factory.newXPath();
tocPath.setNamespaceContext(tocnsc);
Node nav = (Node)tocPath.evaluate("/ncx/navMap", doc, XPathConstants.NODE);
int total = readNavPoint(nav, tocPath, bookdat, 0);
bookdat.put(TOCCOUNT, total);
} catch (ParserConfigurationException | IOException | SAXException | XPathExpressionException e) {
Log.e("BMBF", "Error parsing xml " + e.getMessage(), e);
}
return bookdat;
}
示例8: readVersion
import java.io.BufferedReader; //導入方法依賴的package包/類
/**
* Tests whether a given input stream contains XML format 2, and therefore
* should have the transform applied.
* <p>
* This is designed to match the known output format of
* {@link XmlDataSetConsumer} which previously produced invalid XML. It is
* deliberately brittle. There is no need for a more intelligent XML parser
* here.
* </p>
*
* @param bufferedReader The input stream in a buffered reader
* @return true if the transform should be applied. (because it's format 2)
*/
static int readVersion(BufferedReader bufferedReader) {
try {
bufferedReader.mark(1024); // arbitrary read-ahead limit - that's enough to get the info we want
try {
char[] buffer = new char[1024];
int read = bufferedReader.read(buffer);
if (read == -1) {
return -1;
}
String content = new String(buffer, 0, read);
// Apply the transform if the version number is 2 or 1
Pattern pattern = Pattern.compile("table\\sversion=\"(\\d+)\""); //
Matcher matcher = pattern.matcher(content);
if (!matcher.find()) {
return -1;
} else {
return Integer.parseInt(matcher.group(1));
}
} finally {
bufferedReader.reset();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}