Java Utililty Methods File Touch

List of utility methods to do File Touch

Description

The list of methods to do File Touch are organized into topic(s).

Method

voidtouch(final File f)
touch
PrintWriter writer = new PrintWriter(f);
writer.println("x");
writer.flush();
writer.close();
voidtouch(final File f)
Touch the specified file, creating if necessary.
synchronized (touchLock) {
    if (!f.exists()) {
        new FileOutputStream(f, true).close();
    } else {
        f.setLastModified(System.currentTimeMillis());
booleantouch(final File file)
Update the last modified time of the file to system current time if the specified file exists.
return file.exists() && file.setLastModified(System.currentTimeMillis());
voidtouch(final File file)
touch
if (file.exists()) {
    if (file.isDirectory()) {
        throw new IOException("File '" + file + "' exists but is a directory");
    if (file.canWrite() == false) {
        throw new IOException("File '" + file + "' cannot be written to");
} else {
...
voidtouch(final File folder, final String fileName)
Creates a file
if (!folder.exists()) {
    folder.mkdirs();
final File touchedFile = new File(folder, fileName);
FileOutputStream doneFOS = null;
try {
    doneFOS = new FileOutputStream(touchedFile);
} catch (FileNotFoundException e) {
...
voidtouch(String _filename)
Erstellt eine neue Datei
File file = new File(_filename);
if (true)
    try {
        FileOutputStream ofs = new FileOutputStream(file);
        try {
            ofs.write('!');
        } catch (IOException e) {
...
voidtouch(String answers)
touch
File file = new File(answers);
try {
    file.createNewFile();
} catch (IOException e) {
    throw new RuntimeException(answers, e);
voidtouch(String f)
touch
File file = new File(f);
try {
    if (file.createNewFile() || file.canWrite()) {
        return;
} catch (IOException e) {
throw new IOException("The file is not writable: " + f);
...
booleantouch(String file)
Create a new empty file.
return !exists(file) && (new File(file)).createNewFile();
booleantouch(String file)
Touches a file, so that it's timestamp is right now.
long timestamp = System.currentTimeMillis();
return touch(new File(file).getAbsoluteFile(), timestamp);