"The greatest use of life is to spend it for something that will outlast it"
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Prakash Krsihnan wrote:Inside while check for linenumber is zero then ignore the operation, else proceed as usuals
Srikanth Ravuri wrote:
Prakash Krsihnan wrote:Inside while check for linenumber is zero then ignore the operation, else proceed as usuals
I didn't quit get your point. can you please brief it more.
Thank you,
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
Prakash Krsihnan wrote:Inside while check for linenumber is zero then ignore the operation, else proceed as usuals
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
Sreelatha Sankaranarayanan wrote:This is what will help what you want , note the first 2 lines after the while loop starts -----------
Mohamed Sanaulla wrote:
Prakash Krsihnan wrote:Inside while check for linenumber is zero then ignore the operation, else proceed as usuals
In the code- linenumber is used only at two places-To declare and to increment. It doesn't really affect the CSV parsing process.
Srikanth Ravuri wrote:
Sreelatha Sankaranarayanan wrote:This is what will help what you want , note the first 2 lines after the while loop starts -----------
I am missing in between lines
Output
101 XXXXXX XXXXX 1
103 XXXXXX XXXXX 2
105 XXXXXX XXXXX 3
missing 102 and 104.....
Srikanth Ravuri wrote:
I don't want the 1st line i.e. ID FNAME LNAME DEPTID. Thats where I am stuck.
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
Mohamed Sanaulla wrote:
Srikanth Ravuri wrote:
I don't want the 1st line i.e. ID FNAME LNAME DEPTID. Thats where I am stuck.
In that case- You just have to do-
But suggestion is to use the libraries suggested by Rob. I also mentioned a small glitch in the code in my first post. Also Campbell suggested not using StringTokenizer- You can achieve it by using the split() method of the String class.
Campbell Ritchie wrote:Why are you still using StringTokenizer?
You need some debugging information. Get rid of the tokenising for the time being (comment it out), and print each line as you read it.
Why are you reusing the file name to read into? Why haven't you got a separate local for the String read?
Rob Spoor wrote:Don't reinvent the wheel, and use an existing CSV library. You can find some in our AccessingFileFormats FAQ, under Excel. I myself have used opencsv successfully quite a few times.
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Consider Paul's rocket mass heater. |