Java File Touch touch(String _filename)

Here you can find the source of touch(String _filename)

Description

Erstellt eine neue Datei

License

Open Source License

Parameter

Parameter Description
_filename a parameter

Declaration

synchronized public static void touch(String _filename) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Main {
    /**/* www .  j a  v  a2 s.  co m*/
     * Erstellt eine neue Datei
     * 
     * @param _filename
     */
    synchronized public static void touch(String _filename) {
        File file = new File(_filename);
        if (true)// if (f.canWrite())
        {
            try {
                FileOutputStream ofs = new FileOutputStream(file);
                try {
                    ofs.write('!');
                } catch (IOException e) {
                    e.printStackTrace();
                }
                try {
                    ofs.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }
    }
}

Related

  1. touch(final File f)
  2. touch(final File f)
  3. touch(final File file)
  4. touch(final File file)
  5. touch(final File folder, final String fileName)
  6. touch(String answers)
  7. touch(String f)
  8. touch(String file)
  9. touch(String file)