congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
BufferedReader.mark
Code IndexAdd Tabnine to your IDE (free)

How to use
mark
method
in
java.io.BufferedReader

Best Java code snippets using java.io.BufferedReader.mark (Showing top 20 results out of 1,395)

origin: org.codehaus.groovy/groovy

/**
 * Marks the present position in the stream. Subsequent calls to reset() will attempt to reposition the stream to this point.
 *
 * @param readAheadLimit  Limit on the number of characters that may be read while still preserving the mark.
 *      An attempt to reset the stream after reading characters up to this limit or beyond may fail.
 *      A limit value larger than the size of the input buffer will cause a new buffer to be allocated whose size is no smaller than limit.
 *      Therefore large values should be used with care.
 */
@Override
public void mark(int readAheadLimit) throws IOException {
  lineMark = line;
  columnMark = column;
  super.mark(readAheadLimit);
}
origin: robovm/robovm

/**
 * Sets a mark position in this reader. The parameter {@code readlimit}
 * indicates how many characters can be read before the mark is invalidated.
 * Sending {@code reset()} will reposition this reader back to the marked
 * position, provided that {@code readlimit} has not been surpassed. The
 * line number associated with this marked position is also stored so that
 * it can be restored when {@code reset()} is called.
 *
 * @param readlimit
 *            the number of characters that can be read from this stream
 *            before the mark is invalidated.
 * @throws IOException
 *             if an error occurs while setting the mark in this reader.
 * @see #markSupported()
 * @see #reset()
 */
@Override
public void mark(int readlimit) throws IOException {
  synchronized (lock) {
    super.mark(readlimit);
    markedLineNumber = lineNumber;
    markedLastWasCR = lastWasCR;
  }
}
origin: libgdx/libgdx

public void load (BufferedReader reader) throws IOException {
  super.load(reader);
  // For backwards compatibility, independent property may not be defined
  reader.mark(100);
  String line = reader.readLine();
  if (line == null) throw new IOException("Missing value: " + "independent");
  if (line.contains("independent"))
    independent = Boolean.parseBoolean(readString(line));
  else
    reader.reset();
}
origin: libgdx/libgdx

public void load (BufferedReader reader) throws IOException {
  super.load(reader);
  // For backwards compatibility, independent property may not be defined
  reader.mark(100);
  String line = reader.readLine();
  if (line == null) throw new IOException("Missing value: " + "independent");
  if (line.contains("independent"))
    independent = Boolean.parseBoolean(readString(line));
  else
    reader.reset();
}
origin: marytts/marytts

/**
 * Whether or not any more data can be read from this data source.
 * 
 * @return true if another call to getData() will return data, false otherwise.
 */
public boolean hasMoreData() {
  int c = -1;
  try {
    reader.mark(10);
    c = reader.read();
    reader.reset();
  } catch (IOException ioe) {
    ioe.printStackTrace();
  }
  return c != -1;
}
origin: stanfordnlp/CoreNLP

public static List<SemgrexPattern> compileStream(InputStream is, Env env) throws IOException {
 BufferedReader reader = new BufferedReader(new InputStreamReader(is));
 reader.mark(MAX_STREAM_SIZE);
 Map<String, String> macros = preprocess(reader);
 reader.reset();
 return parse(reader, macros, env);
}
origin: marytts/marytts

/**
 * Whether or not any more data can be read from this data source.
 * 
 * @return true if another call to getData() will return data, false otherwise.
 */
public boolean hasMoreData() {
  int c = -1;
  try {
    reader.mark(10);
    c = reader.read();
    reader.reset();
  } catch (IOException ioe) {
    ioe.printStackTrace();
  }
  return c != -1;
}
origin: kiegroup/optaplanner

public boolean readOptionalConstantLine(String constantRegex) throws IOException {
  bufferedReader.mark(1024);
  boolean valid = true;
  String line = bufferedReader.readLine();
  if (line == null) {
    valid = false;
  } else {
    String value = line.trim();
    if (!value.matches(constantRegex)) {
      valid = false;
    }
  }
  if (!valid) {
    bufferedReader.reset();
  }
  return valid;
}
origin: Rajawali/Rajawali

/**
 * Determine if a given BufferedReader appears to be in ASCII format.
 *
 * @param buffer
 * @return
 * @throws IOException
 */
public static final boolean isASCII(BufferedReader buffer) throws IOException {
  final char[] readAhead = new char[300];
  buffer.mark(readAhead.length);
  buffer.read(readAhead, 0, readAhead.length);
  buffer.reset();
  final String readAheadString = new String(readAhead);
  // If the following text is present, then this is likely an ascii file
  return readAheadString.contains("facet normal") && readAheadString.contains("outer loop");
  // Likely a binary file
}
origin: apache/geode

/** create a stack with the given initial lines, reading the rest from the Reader */
ThreadStack(String firstLine, String secondLine, String thirdLine, BufferedReader reader)
  throws IOException {
 lines.add(firstLine);
 lines.add(secondLine);
 runnable = secondLine.contains("RUNNABLE");
 lines.add(thirdLine);
 String line = null;
 do {
  reader.mark(100000);
  line = reader.readLine();
  if (line == null || line.trim().length() == 0) {
   break;
  }
  if (line.startsWith("\"")) {
   reader.reset();
   break;
  }
  lines.add(line);
 } while (true);
}
origin: embulk/embulk

private void skipBom() {
  boolean skip = false;
  try {
    if (charset.equals(UTF_8)) {
      reader.mark(3);
      int firstChar = reader.read();
      if (firstChar == 0xFEFF) {
        // skip BOM bytes
        skip = true;
      }
    }
  } catch (IOException ex) {
    // Passing through intentionally.
  } finally {
    if (skip) {
      // firstChar is skipped
    } else {
      // rollback to the marked position
      try {
        reader.reset();
      } catch (IOException ex) {
        // unexpected
        throw new RuntimeException(ex);
      }
    }
  }
}
origin: kiegroup/optaplanner

public String readOptionalStringValue(String prefixRegex, String suffixRegex, String defaultValue) throws IOException {
  bufferedReader.mark(1024);
  boolean valid = true;
  String value = bufferedReader.readLine();
  if (value == null) {
    valid = false;
  } else {
    value = value.trim();
    if (value.matches("^" + prefixRegex + ".*")) {
      value = value.replaceAll("^" + prefixRegex + "(.*)", "$1");
    } else {
      valid = false;
    }
    if (value.matches(".*" + suffixRegex + "$")) {
      value = value.replaceAll("(.*)" + suffixRegex + "$", "$1");
    } else {
      valid = false;
    }
  }
  if (!valid) {
    bufferedReader.reset();
    return defaultValue;
  }
  value = value.trim();
  return value;
}
origin: com.h2database/h2

BufferedReader reader = new BufferedReader(new InputStreamReader(in, charset));
reader.mark(1);
if (reader.read() != UTF8_BOM) {
  reader.reset();
origin: lealone/Lealone

BufferedReader reader = new BufferedReader(new InputStreamReader(in, charset));
reader.mark(1);
if (reader.read() != UTF8_BOM) {
  reader.reset();
origin: lealone/Lealone

} else {
  buff = new char[len];
  reader.mark(len);
  len = IOUtils.readFully(reader, buff, len);
origin: com.h2database/h2

} else {
  buff = new char[len];
  reader.mark(len);
  len = IOUtils.readFully(reader, buff, len);
origin: geoserver/geoserver

public void testParseXML() throws Exception {
  URL url = getClass().getResource("applicationContext.xml");
  FileSystemXmlApplicationContext context =
      new FileSystemXmlApplicationContext(url.toString());
  Dispatcher dispatcher = (Dispatcher) context.getBean("dispatcher");
  String body = "<Hello service=\"hello\" message=\"Hello world!\"/>";
  File file = File.createTempFile("geoserver", "req");
  try {
    FileOutputStream output = new FileOutputStream(file);
    output.write(body.getBytes());
    output.flush();
    output.close();
    BufferedReader input =
        new BufferedReader(new InputStreamReader(new FileInputStream(file)));
    input.mark(8192);
    Request req = new Request();
    req.setInput(input);
    Object object = dispatcher.parseRequestXML(null, input, req);
    assertEquals(new Message("Hello world!"), object);
  } finally {
    file.delete();
  }
}
origin: lealone/Lealone

if (max != 0 && max < Integer.MAX_VALUE) {
  BufferedReader b = new BufferedReader(reader, max);
  b.mark(max);
  char[] small = new char[max];
  int len = IOUtils.readFully(b, small, max);
origin: geoserver/geoserver

public void testReadOpPost() throws Exception {
  MockHttpServletRequest request = new MockHttpServletRequest();
  request.setContextPath("/geoserver");
  request.setRequestURI("/geoserver/hello");
  request.setMethod("post");
  String body = "<Hello service=\"hello\"/>";
  DelegatingServletInputStream input =
      new DelegatingServletInputStream(new ByteArrayInputStream(body.getBytes()));
  Dispatcher dispatcher = new Dispatcher();
  BufferedReader buffered = new BufferedReader(new InputStreamReader(input));
  buffered.mark(2048);
  Map map = dispatcher.readOpPost(buffered);
  assertNotNull(map);
  assertEquals("Hello", map.get("request"));
  assertEquals("hello", map.get("service"));
}
origin: spring-projects/spring-batch

@Test
public void testMarkResetWithLineEnding() throws Exception {
  SimpleBinaryBufferedReaderFactory factory = new SimpleBinaryBufferedReaderFactory();
  factory.setLineEnding("||");
  @SuppressWarnings("resource")
  BufferedReader reader = factory.create(new ByteArrayResource("a||b||c".getBytes()), "UTF-8");
  assertEquals("a", reader.readLine());
  reader.mark(1024);
  assertEquals("b", reader.readLine());
  reader.reset();
  assertEquals("b", reader.readLine());
  assertEquals("c", reader.readLine());
  assertEquals(null, reader.readLine());
}
java.ioBufferedReadermark

Javadoc

Sets a mark position in this reader. The parameter markLimitindicates how many characters can be read before the mark is invalidated. Calling reset() will reposition the reader back to the marked position if markLimit has not been surpassed.

Popular methods of BufferedReader

  • <init>
    Creates a buffering character-input stream that uses an input buffer of the specified size.
  • readLine
    Reads a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carr
  • close
    Closes this reader. This implementation closes the buffered source reader and releases the buffer. N
  • read
    Reads characters into a portion of an array. This method implements the general contract of the corr
  • lines
  • ready
    Tells whether this stream is ready to be read. A buffered character stream is ready if the buffer is
  • reset
    Resets the stream to the most recent mark.
  • skip
    Skips characters.
  • markSupported
    Tells whether this stream supports the mark() operation, which it does.
  • checkNotClosed
  • chompNewline
    Peeks at the next input character, refilling the buffer if necessary. If this character is a newline
  • fillBuf
    Populates the buffer with data. It is an error to call this method when the buffer still contains da
  • chompNewline,
  • fillBuf,
  • isClosed,
  • maybeSwallowLF,
  • readChar,
  • fill,
  • ensureOpen,
  • read1

Popular in Java

  • Reactive rest calls using spring rest template
  • onRequestPermissionsResult (Fragment)
  • getResourceAsStream (ClassLoader)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now