4 * License : The MIT License
5 * Copyright(c) 2011 MikuToga Partners
8 package jp.sourceforge.mikutoga.binio;
11 import java.io.FileOutputStream;
12 import java.io.IOException;
13 import java.nio.channels.FileChannel;
18 public final class FileUtils {
26 throw new AssertionError();
31 * 既に存在する通常ファイルか否か判定する。
33 * @return 既に存在する通常ファイルならtrue
35 public static boolean isExistsNormalFile(File file){
36 if( ! file.exists() ) return false;
37 if( ! file.isFile() ) return false;
42 * 既に存在する特殊ファイルか否か判定する。
44 * @return 既に存在する特殊ファイルならtrue
46 public static boolean isExistsUnnormalFile(File file){
47 if( ! file.exists() ) return false;
48 if( file.isFile() ) return false;
54 * <p>既に存在する通常ファイルでないならなにもしない。
56 * @throws IOException 入出力エラー
58 public static void trunc(File file) throws IOException{
59 if( ! isExistsNormalFile(file) ) return;
60 if(file.length() <= 0L) return;
62 FileOutputStream foStream = new FileOutputStream(file);
64 FileChannel channnel = foStream.getChannel();
66 channnel.truncate(0L);
74 assert file.length() <= 0L;