Tabnine Logo
BufferedReader.read
Code IndexAdd Tabnine to your IDE (free)

How to use
read
method
in
java.io.BufferedReader

Best Java code snippets using java.io.BufferedReader.read (Showing top 20 results out of 86,454)

Refine searchRefine arrow

  • BufferedReader.<init>
  • InputStreamReader.<init>
  • BufferedReader.close
  • PrintStream.println
  • FileReader.<init>
origin: stackoverflow.com

BufferedReader br = new BufferedReader(new InputStreamReader(System.in, Charset.forName("ISO-8859-1")),1024);
 // ...
    // inside some iteration / processing logic:
    if (br.ready()) {
      int readCount = br.read(inputData, bufferOffset, inputData.length-bufferOffset);
    }
origin: libgdx/libgdx

        @Override
        public void run () {
          BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()), 1);
          try {
            int c = 0;
            while ((c = reader.read()) != -1) {
              callback.character((char)c);						
            }
          } catch (IOException e) {
//                        e.printStackTrace();
          }
        }
      });
origin: stanfordnlp/CoreNLP

private void readRawBytes(String fileName) throws IOException {
 BufferedReader in = new BufferedReader(new FileReader(fileName));
 StringBuffer buf = new StringBuffer();
 int c;
 while ((c = in.read()) >= 0)
  buf.append((char) c);
 mRawBuffer = buf.toString();
 // System.out.println(mRawBuffer);
 in.close();
}
origin: cymcsg/UltimateAndroid

/**
 * Gzip file.
 *
 * @param zipFileName
 * @param mDestFile
 * @throws Exception
 */
public static void gzips(String zipFileName, String mDestFile) throws Exception {
  BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(zipFileName), "UTF-8"));
  BufferedOutputStream out = new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(mDestFile)));
  int c;
  while ((c = in.read()) != -1) {
    out.write(String.valueOf((char) c).getBytes("UTF-8"));
  }
  in.close();
  out.close();
}
origin: jamesdbloom/mockserver

public static String readInputStreamToString(Socket socket) throws IOException {
  BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
  StringBuilder result = new StringBuilder();
  String line;
  Integer contentLength = null;
  while ((line = bufferedReader.readLine()) != null) {
    if (line.startsWith("content-length") || line.startsWith("Content-Length")) {
      contentLength = Integer.parseInt(line.split(":")[1].trim());
    }
    if (line.length() == 0) {
      if (contentLength != null) {
        result.append(NEW_LINE);
        for (int position = 0; position < contentLength; position++) {
          result.append((char) bufferedReader.read());
        }
      }
      break;
    }
    result.append(line).append(NEW_LINE);
  }
  return result.toString();
}
origin: marytts/marytts

public static String getReaderAsString(Reader reader) throws IOException {
  StringWriter sw = new StringWriter();
  BufferedReader in = new BufferedReader(reader);
  char[] buf = new char[8192];
  int n;
  while ((n = in.read(buf)) > 0) {
    sw.write(buf, 0, n);
  }
  return sw.toString();
}
origin: dcm4che/dcm4che

private static void printNextStepMessage(String message) throws IOException {
  System.out.println("===========================================================");
  System.out.println(message + ". Press <enter> to continue.");
  System.out.println("===========================================================");
  bufferedReader.read();
}
origin: JetBrains/ideavim

 @NotNull
 private static String readFile(@NotNull File file) throws IOException {
  final BufferedReader reader = new BufferedReader(new FileReader(file));
  final StringBuilder builder = new StringBuilder();
  final char[] buffer = new char[BUFSIZE];
  int n;
  while ((n = reader.read(buffer)) > 0) {
   builder.append(buffer, 0, n);
  }
  return builder.toString();
 }
}
origin: org.drools/drools-core

  public String readInputStreamReaderAsString(InputStreamReader in) throws IOException {
    StringBuffer fileData = new StringBuffer(1000);
    BufferedReader reader = new BufferedReader(in);
    char[] buf = new char[1024];
    int numRead = 0;
    while ((numRead = reader.read(buf)) != -1) {
      String readData = String.valueOf(buf, 0, numRead);
      fileData.append(readData);
      buf = new char[1024];
    }
    reader.close();
    return fileData.toString();
  }
}
origin: sleekbyte/tailor

  /**
   * Checks whether a file contains any leading whitespace characters.
   *
   * @param inputFile the file to check for leading whitespace
   * @return true if file starts with whitespace
   * @throws IOException if the file cannot be read
   */
  public static boolean hasLeadingWhitespace(File inputFile) throws IOException {
    BufferedReader reader = Files.newBufferedReader(inputFile.toPath());
    int character = reader.read();
    if (character != -1 && Character.isWhitespace((char) character)) {
      return true;
    }
    reader.close();
    return false;
  }
}
origin: ainilili/ratel

/**
 * Convert input stream to string
 * 
 * @param inStream Input stream
 * @return {@link String}
 * @throws IOException If an I/O error occurs
 */
public static String convertToString(InputStream inStream){ 
  BufferedReader br = new BufferedReader(new InputStreamReader(inStream));  
  StringBuilder reqStr = new StringBuilder();  
  char[] buf = new char[2048];  
  int len = -1;
  try {
    while ((len = br.read(buf)) != -1) {  
      reqStr.append(new String(buf, 0, len));  
    }  
    br.close();
  }catch(IOException e) {
    return null;
  }finally {
    try {
      br.close();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  return reqStr.toString();
}

origin: stanfordnlp/CoreNLP

 public static void main(String argv[]) throws Exception {
  if(argv.length != 1){
   log.info("Usage: java edu.stanford.nlp.ie.machinereading.common.RobustTokenizer <file to tokenize>");
   System.exit(1);
  }

  // tokenize this file
  BufferedReader is = 
   new BufferedReader(new FileReader(argv[0])); 

  // read the whole file in a buffer
  // XXX: for sure there are more efficient ways of reading a file...
  int ch;
  StringBuffer buffer = new StringBuffer();
  while((ch = is.read()) != -1) buffer.append((char) ch);
  
  // create the tokenizer object
  RobustTokenizer<Word> t = new RobustTokenizer<>(buffer.toString());

  List<Word> tokens = t.tokenize();
  for (Word token : tokens) {
   System.out.println(token);
  }
 }
}
origin: org.assertj/assertj-core

private static String loadContents(InputStream stream, Charset charset) throws IOException {
 try (StringWriter writer = new StringWriter();
   BufferedReader reader = new BufferedReader(new InputStreamReader(stream, charset))) {
  int c;
  while ((c = reader.read()) != -1) {
   writer.write(c);
  }
  return writer.toString();
 }
}
origin: ltsopensource/light-task-scheduler

private HttpCmdRequest parseRequest() throws Exception {
  BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8"));
    int read = in.read(buf);
    while (read >= 0 && size > 0 && !postLine.endsWith("\r\n")) {
      size -= read;
      postLine += String.valueOf(buf, 0, read);
      if (size > 0)
        read = in.read(buf);
origin: marytts/marytts

public static String getReaderAsString(Reader reader) throws IOException {
  StringWriter sw = new StringWriter();
  BufferedReader in = new BufferedReader(reader);
  char[] buf = new char[8192];
  int n;
  while ((n = in.read(buf)) > 0) {
    sw.write(buf, 0, n);
  }
  return sw.toString();
}
origin: stackoverflow.com

private static String File2String(String fileName) throws
     java.io.FileNotFoundException, java.io.IOException
 {
     File file = new File(fileName);
     char[] buffer = null;
     BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
     buffer = new char[(int)file.length()];
     int i = 0;
     int c = bufferedReader.read();
     while (c != -1) {
         buffer[i++] = (char)c;
         c = bufferedReader.read();
     }
     return new String(buffer);
 }
origin: geoserver/geoserver

/**
 * Constructor with raw request string. Calls parent.
 *
 * @param reader A reader of the request from the http client.
 * @param req The actual request made.
 * @throws ServiceException DOCUMENT ME!
 * @throws IOException
 */
public void read(BufferedReader requestReader, HttpServletRequest req)
    throws ServiceException, IOException {
  final StringBuffer output = new StringBuffer();
  int c;
  while (-1 != (c = requestReader.read())) {
    output.append((char) c);
  }
  requestReader.close();
  this.queryString = output.toString();
  this.requestParams = KvpRequestReader.parseKvpSet(this.queryString);
}
origin: kaaproject/kaa

/**
 * Read file.
 *
 * @param file the file
 * @return the string
 * @throws IOException Signals that an I/O exception has occurred.
 */
static String readFile(File file) throws IOException {
 String result = null;
 try {
  StringBuffer fileData = new StringBuffer();
  FileInputStream input = new FileInputStream(file);
  BufferedReader reader = new BufferedReader(new InputStreamReader(input));
  char[] buf = new char[1024];
  int numRead = 0;
  while ((numRead = reader.read(buf)) != -1) {
   String readData = String.valueOf(buf, 0, numRead);
   fileData.append(readData);
  }
  reader.close();
  result = fileData.toString();
 } catch (IOException ex) {
  LOG.error("Unable to read from specified file '"
    + file + "'! Error: " + ex.getMessage(), ex);
  throw ex;
 }
 return result;
}
origin: cSploit/android

BufferedReader reader = new BufferedReader(new FileReader(fileName));
char[] buf = new char[1024];
int read = 0;
String js = "";
while((read = reader.read(buf)) != -1){
 buffer.append(String.valueOf(buf, 0, read));
reader.close();
origin: joel-costigliola/assertj-core

private static String loadContents(InputStream stream, Charset charset) throws IOException {
 try (StringWriter writer = new StringWriter();
   BufferedReader reader = new BufferedReader(new InputStreamReader(stream, charset))) {
  int c;
  while ((c = reader.read()) != -1) {
   writer.write(c);
  }
  return writer.toString();
 }
}
java.ioBufferedReaderread

Javadoc

Reads a single character from this reader and returns it with the two higher-order bytes set to 0. If possible, BufferedReader returns a character from the buffer. If there are no characters available in the buffer, it fills the buffer and then returns a character. It returns -1 if there are no more characters in the source reader.

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
  • 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.
  • mark
    Marks the present position in the stream. Subsequent calls to reset() will attempt to reposition the
  • 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

  • Reading from database using SQL prepared statement
  • startActivity (Activity)
  • findViewById (Activity)
  • onRequestPermissionsResult (Fragment)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • Top 17 PhpStorm Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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