Class Notes (1,100,000)
US (480,000)
UW-Madison (5,000)
Lecture 32

COMP SCI 200 Lecture Notes - Lecture 32: Working Directory, Mkdir


Department
Computer Sciences
Course Code
COMP SCI 200
Professor
Marc Renault
Lecture
32

This preview shows page 1. to view the full 4 pages of the document.
Comp Sci 200- Lecture 32- File Input and Output pt 2
File I/O
File Class
java.io.File
Constructor
File f = new File(pathToFile)
Creates a File object, but not a logical file
An empty file is created
pathToFile
All instance methods are based on this path
Permissions
boolean canRead()- Can read the contents?
boolean canWrite()- Can change the contents?
boolean canExecute()- Can execute the path?
There are also methods to set the permissions
File tests
boolean exists()- Does the file exist?
boolean isFile()- Is it a normal file?
boolean isDirectory()- Is it a directory?
boolean isHidden()- Is it hidden?
Other file properties
long lastModified()- Date last modified
long length()- Number of bytes
String getPath()- Returns the path
String getAbsolutePath()- Returns the absolute path
Absolute paths start with a “\
find more resources at oneclass.com
find more resources at oneclass.com
You're Reading a Preview

Unlock to view full version