Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

open directory and read all files  RSS feed

 
mehedi hasan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

hi,
i am very new in java. right now facing one problem to read many files from one folder. suppose i have few txt files in one folder and every txt files contain some my friends name.

my program should open that folder and read all files one by one to find all friends name.

so far i have done it from one particular txt file but i cant make it from many files within a folder.

can anybody please help me.....
1st code that i used to find from one particular file

2nd code where i am trying for many files, it has no errors but no output.

 
Joe Ess
Bartender
Posts: 9425
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A pathname, whether abstract or in string form, may be either absolute or relative. An absolute pathname is complete in that no other information is required in order to locate the file that it denotes. A relative pathname, in contrast, must be interpreted in terms of information taken from some other pathname. By default the classes in the java.io package always resolve relative pathnames against the current user directory. This directory is named by the system property user.dir, and is typically the directory in which the Java virtual machine was invoked.

java.io.File

You may want to print out the file names/paths you are trying to open.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!