Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

check values in a csv file in all files in a directory

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ihave a csv file, it has 1000 values, I have to take each value in the csv file and check whether that value is there any of the files in folders of a directory.

How do I do that? Is anybody implemeted this code?

I used below code, it does not work for me, it gives me IO Error Occurred: java.io.FileNotFoundException: C:\myfile\100_5720 (Access is denied) , it throws

 
prince davies
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

i have not added code for reading csv file and getting each value from it , loop thru the files in the folders. in my question, i hardcoded one value = believe
 
prince davies
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I used the following code for checking values in csv file in fles in folders in a directory. But it throws an exception










why does it thow file not found excption : (Access is denied)
 
prince davies
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


searchFile = new BufferedReader(new FileReader(f));

problem is @ new FileReader(f)

the above line returned me java.io.FileNotFoundException: C:\PROJECTS\CODE\2012-JULY-DEV\vobs\src\sdt\source\java\com (Access is denied)

it could read first file. but this is a folder with no file in it.
 
prince davies
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have run the following program, its working fine now. I want to know how I can optimize this program. Please help me ASAP.


 
Bartender
Posts: 7488
171
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Simple though it is, there's more to CSV than what code implements. If this was my problem I'd use a CSV library like the ones listed in the https://coderanch.com/how-to/java/AccessingFileFormats page.
 
Don't count your weasels before they've popped. And now for a mulberry bush related tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic