The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
September 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

yup

Posted by Chin Loong on September 25, 2001 at 1:13 AM

> [javacode]
> import java.io.*;
> public class CheckFile
> {
> public static void main(String[] args)
> {
> File f = new File("data.txt");
> if(f.exists())
> {
> System.out.println(f.getName() + " exists");
> System.out.println
> ("The file is " + f.length() + "bytes long");
> if(f.canRead())
> System.out.println(" ok to read");
> if(f.canWrite())
> System.out.println(" ok to write");
> }
> else
> System.out.println("File does not exit");
> }
> }
> [/javacode]

> In the above is the data type of f File?

> Is File a class?

> new File creates an instance of the File class. This instance is the object data.txt, am i correct?

> f.exists, f.getName etc they are methods arent they?

u answered all your questions





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us