Solved

inputFileMsg as String object from file

Posted on 2014-02-28
2
549 Views
Last Modified: 2014-02-28
Hi,

I am going through below example

http://bethecoder.com/applications/tutorials/tools-and-libs/commons-io/basic/line-iterator.html


Code looks like below

import org.apache.commons.io.LineIterator;

public class LineIteratorTest {

  /**
   * @param args
   * @throws IOException
   */
  public static void main(String[] args) throws IOException {
    File file = new File("C:/Test/rule_engine_names.txt");
    LineIterator lineIt = FileUtils.lineIterator(file, "UTF-8");
   
    while (lineIt.hasNext()) {
      System.out.println(lineIt.next());
//Here i need to somehow prepare inputFileMsg as String object
    }
   
    LineIterator.closeQuietly(lineIt);
  }
}  
 
   
 

//LAter I need to call
parseMsgFile(inputFileMsg);

other method looks like this


      public Object parseMsgFile(String inputFileMsg) throws Exception {

...
}


How to prepare inputFileMsg as String object?


please advise
Any links resources ideas highly appreciated. Thanks in advance
0
Comment
Question by:gudii9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 39895522
I suspect that class is pretty old (it would be redundant if invented after Scanner)

If you want to turn a file into a String:

http://technojeeves.com/index.php/aliasjava1/57-file-to-string-in-java
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39895769
:)
0

Featured Post

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question