// Copyright (C) 2015 anduo // All rights reserved package com.anduo.filesync.util; import com.anduo.filesync.core.FileMsgServer; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; import java.io.Closeable; import java.io.File; import java.io.IOException; /** * ━━━━━━神兽出没━━━━━━ *    ┏┓   ┏┓ *   ┏┛┻━━━┛┻┓ *   ┃       ┃ *   ┃   ━   ┃ *   ┃ ┳┛ ┗┳ ┃ *   ┃       ┃ *   ┃   ┻   ┃ *   ┃       ┃ *   ┗━┓   ┏━┛ *     ┃   ┃神兽保佑, 永无BUG! *     ┃   ┃Code is far away from bug with the animal protecting *     ┃   ┗━━━┓ *     ┃       ┣┓ *     ┃       ┏┛ *     ┗┓┓┏━┳┓┏┛ *      ┃┫┫ ┃┫┫ *      ┗┻┛ ┗┻┛ * ━━━━━━感觉萌萌哒━━━━━━ * Summary: TODO 描述信息 * Author : anduo@qq.com * Version: 1.0 * Date : 15/7/5 * time : 17:00 */ public class CleanUpUtil { public static void closeOnFlush(Channel ch) { if (ch.isActive()) { ch.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE); } } public static void closeQuietly(Closeable c) { try { if (c != null) c.close(); } catch (IOException ignored) { } } public static boolean deleteFile(String fileName) { File file = new File(FileMsgServer.POLICY_FILE); return file.exists() && file.delete(); } }