Java Reference
In-Depth Information
public static File createTempFile(String prefix, String suffix)
tHRows IOException
Equivalent to createTempFile(prefix,suffix, null) .
public void deleteOnExit()
Requests the system to remove the file when the virtual ma-
chine terminatessee " Shutdown " on page 672 . This request
only applies to a normal termination of the virtual machine
and cannot be revoked once issued.
When a temporary file is created, the prefix and the suffix may first be
adjusted to fit the limitations of the underlying platform. If the prefix
is too long then it will be truncated, but its first three characters will
always be preserved. If the suffix is too long then it too will be trun-
cated, but if it begins with a period ( . ) then the period and the first three
characters following it will always be preserved. Once these adjustments
have been made the name of the new file will be generated by concat-
enating the prefix, five or more internally generated characters, and the
suffix. Temporary files are not automatically deleted on exit, although
you will often invoke deleteOnExit on File objects returned by createTem-
pFile .
Finally, the character File.pathSeparatorChar and its companion string
File.pathSeparator represent the character that separates file or direct-
ory names in a search path. For example, UNIX separates components in
the program search path with a colon, as in ".:/bin:/usr/bin" , so pathSe-
paratorChar is a colon on UNIX systems.
Exercise 20.9 : Write a method that, given one or more pathnames, will
print all the information available about the file it represents (if any).
Exercise 20.10 : Write a program that uses a StreamTokenizer object to
break an input file into words and counts the number of times each word
occurs in the file, printing the result. Use a HashMap to keep track of the
words and counts.
 
Search WWH ::




Custom Search