How to read CSV File using Java StringTokenizer

Reading CSV file is required often in java projects. Instead of using parsing it manually via array or something like that. This sample shows how to parse comma separated file using Java StringTokenizer or read csv file using Java StringTokenize.

Parse CSV File using StringTokenizer

Input data

"Banana","Apple","Orange","Kiwi"
"Mango","Lemon","Cherry","Grape","Tomato","Strawberry"

Output

Line number: 1, Token number: 1, Token : "Banana"
Line number: 1, Token number: 2, Token : "Apple"
Line number: 1, Token number: 3, Token : "Orange"
Line number: 1, Token number: 4, Token : "Kiwi"
Line number: 2, Token number: 1, Token : "Mango"
Line number: 2, Token number: 2, Token : "Lemon"
Line number: 2, Token number: 3, Token : "Cherry"
Line number: 2, Token number: 4, Token : "Grape"
Line number: 2, Token number: 5, Token : "Tomato"
Line number: 2, Token number: 6, Token : "Strawberry"

That’s all on how to read csv file using java StringTokenize. Welcome any comment if you have other way to do this thing.

Leave a Comment

*

Please share it if you found this useful
Hide Buttons