Professional Documents
Culture Documents
• Delete File
File file = new File("c:\\data\\input-file.txt");
boolean success = file.delete();
Mrs. Chavan P.P.
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.
Constructor Description
FileWriter(File file) creates a new file. It gets file name in File object.
fr.close();
}
}
ArrayList al=new
Mrs. Chavan P.P.
ArrayList();
Methods of Array list
Method Description
void add(int index, Object element) Inserts the specified element at the
specified position index in this list.
void clear() Removes all of the elements from this list.
boolean contains(Object o) Returns true if this list contains the specified
element.
int indexOf(Object o) Returns the index in this list of the first
occurrence of the specified element, or -1 if
the List does not contain this element.
int lastIndexOf(Object o) Returns the index in this list of the last
occurrence of the specified element, or -1 if
the list does not contain this element.
Object remove(int index) Removes the element at the specified
position in this list.
Object get(int index) Returns the element at the specified
position in this list.
Mrs. Chavan P.P.
Date Class
• Java provides the Date class available
in java.util package. It provides constructors
and methods to deal with date and time in
java.
• Constructors
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
betweenMrs.
1 and
Chavan31
P.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
add( ) Adds an object to the collection.
Method Description