Solved

inputFileMsg as String object from file

Posted on 2014-02-28
2
540 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unable to start eclipse ? 17 132
sites similar to codingbat to improve coding hanson skills 3 41
simple java question 3 44
ForLoop Example 3 40
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now