File processing using Java

Posted on 2003-03-25
Medium Priority
Last Modified: 2010-04-17

How can I read a pipe delimited multi-record file using Java, make some data conversions/modifications to the elements of the file and write the updated input file elements to a pipe delimited output file?

For example, if the input file is as follows:

ABC|566.44|383|Visual Basic|ASP

Convert 4th field ("Java" to "Programming" and "Visual Basic" to "Windows") and divide the 3rd field by 100.

My output file should be like this:


Thanks for your help.

Question by:sri_bali
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
LVL 30

Accepted Solution

Mayank S earned 300 total points
ID: 8208043
1. Read the file line-by-line using BufferedReader and readLine ().

2. Use a StringTokenizer to de-limit the string at pipes ( | ) and copy the four substrings into an array of Strings.

3. Perform what-ever operations/ modifications you have to perform, converting the String to integer-type using Integer.parseInt () wherever required.

4. Write the output in the same fashion into another file, converting integers to Strings using Integer.toString (), delimiting the strings by pipes ( | ).


Expert Comment

ID: 9446805
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.
LVL 30

Expert Comment

by:Mayank S
ID: 9451892
Recommendation: Accept mayankeagle's comment as answer.

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this post we will learn different types of Android Layout and some basics of an Android App.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Simple Linear Regression

800 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