Here you can find the source of emptyFile(String srcFilename)
public static void emptyFile(String srcFilename) throws IOException
//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 { public static void emptyFile(String srcFilename) throws IOException { File srcFile = new File(srcFilename); if (!srcFile.exists()) { throw new FileNotFoundException("Cannot find the file: " + srcFile.getAbsolutePath()); }//from w ww. j av a2 s .c om if (!srcFile.canWrite()) { throw new IOException("Cannot write the file: " + srcFile.getAbsolutePath()); } FileOutputStream outputStream = new FileOutputStream(srcFilename); outputStream.close(); } }