简体   繁体   中英

Parse a Comma Delimited File using JAVA

I want to read this file:-

http://www.somehost.com/products/, A0,D1,L0,T0
http://www.somehost.com/news/rel, A1,D0,L1,T0
http://istor.somehost.com, A0, D1, L0, T0

I have a list of urls and I want to compare those url's with the url's that are there in this file. And Suppose the url that I wanted to compare starts with the url that is there in these file.. Then it will move forward in that url line and it will check for A and D. If A is 0 then we will not crawl that url and vice versa and If A is 1 then we will move forward and see whether L is 0 or 1 means if L is 1 then we will extract link only and vice versa and same with T is 0 or 1, we will extract text only if T is 0.

Any suggestion how can I do this.. ??

I've used Java CSV and it's pretty easy. See the code examples as well. However (summarizing what @Hovercraft Full Of Eels said), if your data are not overly complicated, Java's String.split() should work fine.

After parsing your data you can, you know, read the values and determine what to do from there. Your description of what you need to do is practically an outline of a method with an if ... else if ... else structure, so start from that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM