Forums Register Login

Need Help - Read a file from client

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 710 times.
Similar Threads
reading a URL
RMI help
WSAD - How to read/find text file.
Java File Error - Format Issue
Java Applet
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 03:53:31.