Unit 6 - Io Basics
Unit 6 - Io Basics
• Delete File
File file = new File("c:\\data\\input-file.txt");
boolean success = file.delete();
Mrs. Madhuri V. Desai
Stream Classes
• Stream Classes
➢ Java performs I/O through Streams. A Stream is
linked to a physical layer by java I/O system to
make input and output operation in java.
➢ A stream means continuous flow of data.
}
FileInputStream
• The Java.io.FileInputStream class obtains
input bytes from a file in a file system.
• FileInputStream class is meant for reading
streams of raw bytes such as image data.
Constructor Description
FileWriter(File file) creates a new file. It gets file name in File object.
fr.close();
}
}
Constructor Description
Date() Creates a date object representing
current date and time.
Date(long milliseconds) Creates a date object for the given
milliseconds since January 1, 1970,
00:00:00 GMT.
Mrs. Chavan P.P.
Methods Date Class
Method Description
boolean after(Date date) tests if current date is after the given date.
boolean before(Date date) tests if current date is before the given date.
Object clone() returns the clone object of current date.
int compareTo(Date date) compares current date with given date.
boolean equals(Date date) compares current date with given date for equality.
long getTime() returns the time represented by this date object.
Returns the day of the week represented by this date.
The returned value (0 = Sunday, 1 = Monday, 2 =
public int getDay()
Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 =
Saturday) represents the day of the week.
void setTime(long time) changes the current date and time to given time.
Returns the day of the month represented by
public int getDate() this Date object. The value returned is
betweenM1rs.aCnhadvan3P1.P. representing the day of the month
set Interface
• The Set interface contains only methods
inherited from Collection and adds the
restriction that duplicate elements are
prohibited.
• It models the mathematical set abstraction.
Method Description