• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to read the contents inside the directory folder  RSS feed

 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ,

i have created a program to read the file name from the directory. now i am trying to read the contents inside the file in the directory. But i am unable to proceed ? can any one help me ?



the directory file contains various folders like student , employee
in student it contains details as follows

1:NAME
2:REGISTER NUMBER
3:STANDARD
4:SCHOOL NAME

in employee file it has contents like this

1: NAME
2:ID
3:SALARY

I am trying to get the result of both the files in output. the code for reading a file inside the directory i have got. how to combine the two files and get the output ?


Hope i am clear!
 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can see what structure the records have when you print them out. You might do well to use some sort of splitting of the line, depending what sort of delimiter was used. Are you using tabs or commas or what? I can’t say more than that at present.
you should consider a Scanner rather than buffered readers.

That sort of thing would, in real life, be done with database connections.
I presume the listing of how many files there are in the directory and the printing of the file contents are separate programs?
 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
deepika deepi wrote:I am trying to get the result of both the files in output. the code for reading a file inside the directory i have got. how to combine the two files and get the output ?

Well, the first thing I see is that you define a String called 'extended', but never use it.

Second: I'm always wary of methods that return void; especially when they're used recursively. In general, you want the next level of recursion to hand back a result that can be used by the previous level. In your case, I think I'd be tempted to make it a List<File>, which I then use to populate an instance-level List; but there are probably many other ways that would work just as well.

Winston
 
deepika deepi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie
I presume the listing of how many files there are in the directory and the printing of the file contents are separate programs?


no yaar. i have two separate programs for reading the contents from the directory and next read the file insider that directory. i am trying to get both in the same coding. After reading the contents in the directory i would like to get the output of file contents from that coding itself(i.e) i want to combine the two coding to one and get the output of contents of student record from the dir file
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!