• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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.


 
Saloon Keeper
Posts: 7582
176
  • 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.
 
You will always be treated with dignity. Now, strip naked, get on the probulator and hold this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic