• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need Help - Read a file from client  RSS feed

 
Ahsan Hadi
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all the java bofins, Since i am new to this arena of object oriented programming I need some help.
I am trying to write a client java program which read a text file from a local drive. First check's the creation and modification date of that file and then Interogates it by going through the text in the file and then display a Message accordingly.
Thanks any help with be greatly appreciated.
regards,
Ahsan.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The File class has a lastModified() method to find out when the file was last modified. I don't know a way to find out file creation time in Java - this info isn't available on all operating systems, so they left it out of the API. However you can make system-specific calls using Runtime's exec() method, or using JNI (Java Native Interface) to call a utility written in another language. You also may be able to get information by attempting to read the directory a if it were a file - though this could well simply give you some sort of IOException.
To read from a file, use FileInputStream or FileReader. See the Java Tutorial on I/O (or any good introductory Java book) if you're new to I/O in Java.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!