Package com.google.common.io

Examples of com.google.common.io.LineReader


    generator = mapper.getJsonFactory().createJsonGenerator(new File(OUTPUT_FILE), JsonEncoding.UTF8);
  }

  public void process() throws IOException {
    final FileReader fileReader = new FileReader(new File(INPUT_FILE));
    final LineReader reader = new LineReader(fileReader);
    try {
      JsonNode obj;
      String line;
      while ((line = reader.readLine()) != null) {
        obj = mapper.readTree(line);
        this.convertRatedOutputCurrent(obj);
        this.convertRatedOutputVoltage(obj);
        this.convertRatedOutputkW(obj);
        this.convertLatitude(obj);
View Full Code Here


   * JSON object, add it to the index, and commit the documents at the end of
   * the process.
   */
  public void index(final File input) throws IOException, SolrServerException {
    logger.info("Loading JSON objects from {}", input);
    final LineReader reader = new LineReader(new FileReader(input));

    int counter = 0;
    String line;
    while ((line = reader.readLine()) != null) {
      server.add(this.parseObject(line));
      counter++;
    }
    server.commit();
    logger.info("Loaded {} JSON objects", counter);
View Full Code Here

    InetSocketAddress socketAddress = discoverables.iterator().next().getSocketAddress();
    Socket socket = new Socket(socketAddress.getAddress(), socketAddress.getPort());
    try {
      PrintWriter writer = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), Charsets.UTF_8), true);
      LineReader reader = new LineReader(new InputStreamReader(socket.getInputStream(), Charsets.UTF_8));

      String msg = "Local file test";
      writer.println(msg);
      Assert.assertEquals(header, reader.readLine());
      Assert.assertEquals(msg, reader.readLine());
    } finally {
      socket.close();
    }

    controller.stopAndWait();
View Full Code Here

      Socket socket = new Socket(discoverable.getSocketAddress().getAddress(),
                                 discoverable.getSocketAddress().getPort());
      try {
        PrintWriter writer = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), Charsets.UTF_8), true);
        LineReader reader = new LineReader(new InputStreamReader(socket.getInputStream(), Charsets.UTF_8));

        writer.println(msg);
        Assert.assertEquals(msg, reader.readLine());
      } finally {
        socket.close();
      }
    }
View Full Code Here

  }
 
  private static ParsedSql _parseSql(String sql, SqlPlaceholderParserConfig config) throws IOException {
   
    StringBuilder sb = new StringBuilder(sql.length());
    LineReader lr = new LineReader(new StringReader(sql));
    String line;
    ImmutableList.Builder<PlaceHolder> placeHolders = ImmutableList.builder();
    int nameIndex = 0;
    int positionalIndex = 0;
    int position = 0;
    boolean first = true;
   
    while ( (line = lr.readLine()) != null) {
      if (first) first = false;
      else sb.append("\n");
      Matcher m = tokenPattern.matcher(line);
      if (m.matches()) {
        String leftHand = m.group(1);
View Full Code Here

    StreamReader(Reader reader) {
      this.reader = reader;
    }
   
    @Override public Void call() throws IOException, InterruptedException, ParseException {
      LineReader lineReader = new LineReader(reader);
      boolean threw = true;
      try {
        String line;
        while ((line = lineReader.readLine()) != null) {
          LogMessage logMessage = logMessageParser.parse(line);
          if (options.verbose() && !(logMessage instanceof CaliperControlLogMessage)) {
            stdout.printf("[trial-%d] %s%n", trialNumber, line);
          }
          outputQueue.put(new StreamItem(logMessage));
View Full Code Here

  }
 
 
  private static FileDeclarationSql _processFile(String path, String sql) throws IOException {
   
    LineReader lr = new LineReader(new StringReader(sql));
    String line;
    ImmutableList.Builder<ReferenceSql> references = ImmutableList.builder();
    ImmutableMap.Builder<String,HashDeclarationSql> hashes = ImmutableMap.builder();
    ImmutableList.Builder<ReferenceSql> hashReferences = ImmutableList.builder();
    Map<String, HashDeclarationSql> nameToHash = newHashMap();
   
    ImmutableList.Builder<String> referenceContent = ImmutableList.builder();
    ImmutableList.Builder<String> hashContent = ImmutableList.builder();
    ImmutableList.Builder<String> fileContent = ImmutableList.builder();

   
    boolean first = true;
    PSTATE state = PSTATE.OTHER;
    PSTATE previousState = PSTATE.OTHER;
   
    String currentHash = null;
    String currentReference = null;
    Map<String,List<String>> currentReferenceParameters = ImmutableMap.of();
    int hashStartIndex = 0;
    int referenceStartIndex = 0;
    int lineIndex = 0;
   
    String PE = "For path: '{}', ";
   
    while ( (line = lr.readLine()) != null) {
      if (first) first = false;
      Matcher m = tokenPattern.matcher(line);
      String tag;
      if (m.matches() && (tag = m.group(1)) != null && ! (tag = tag.trim()).isEmpty()) {
        if (tag != null && tag.startsWith("#")) {
View Full Code Here

      try {
        Socket socket = serverSocket.accept();
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), "UTF-8"));
        try {
          // Read the client command and dispatch
          String command = new LineReader(new InputStreamReader(socket.getInputStream(), "UTF-8")).readLine();
          CommandHandler handler = handlers.get(command);

          if (handler != null) {
            try {
              handler.handle(writer);
View Full Code Here

    public String blame(XmlDocument xmlDocument)
            throws IOException, SAXException, ParserConfigurationException {

        ImmutableMultimap<Integer, Record> resultingSourceMapping =
                getResultingSourceMapping(xmlDocument);
        LineReader lineReader = new LineReader(
                new StringReader(xmlDocument.prettyPrint()));

        StringBuilder actualMappings = new StringBuilder();
        String line;
        int count = 1;
        while ((line = lineReader.readLine()) != null) {
            actualMappings.append(count).append(line).append("\n");
            if (resultingSourceMapping.containsKey(count)) {
                for (Record record : resultingSourceMapping.get(count)) {
                    actualMappings.append(count).append("-->")
                            .append(record.getActionLocation().toString())
View Full Code Here

    for (Discoverable discoverable : discoverables) {
      InetSocketAddress socketAddress = discoverable.getSocketAddress();
      Socket socket = new Socket(socketAddress.getAddress(), socketAddress.getPort());
      try {
        PrintWriter writer = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), Charsets.UTF_8), true);
        LineReader reader = new LineReader(new InputStreamReader(socket.getInputStream(), Charsets.UTF_8));

        String msg = "Failure";
        writer.println(msg);

        String line = reader.readLine();
        Assert.assertTrue(line.endsWith(msg));
        instances.add(Integer.parseInt(line.substring(0, line.length() - msg.length())));
      } finally {
        socket.close();
      }
View Full Code Here

TOP

Related Classes of com.google.common.io.LineReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.