Browse Source

Merge remote-tracking branch 'origin/dev' into dev

wangdy 8 years ago
parent
commit
5dfb16c990

+ 0 - 133
src/main/java/com/uas/ps/product/util/FileBuffer.java

@@ -1,133 +0,0 @@
-package com.uas.ps.product.util;
-
-import java.io.*;
-
-/**
- * @author sunyj
- * @since 2018/1/6 17:39
- */
-public class FileBuffer {
-    private String filePath;
-    private BufferedWriter writer;
-    private BufferedReader reader;
-
-    public FileBuffer(String folderPath, String fileName) {
-        File file = new File(folderPath);
-        if (!file.isDirectory()) {
-            file.mkdirs();
-        }
-
-        this.filePath = folderPath + File.separator + fileName;
-    }
-
-    public synchronized boolean append(String content) {
-        if (this.writer == null) {
-            try {
-                File file = new File(this.filePath);
-                if (!file.exists()) {
-                    file.createNewFile();
-                }
-
-                this.writer = new BufferedWriter(new FileWriter(file, true));
-            } catch (IOException var5) {
-                return false;
-            }
-        } else {
-            try {
-                this.writer.write("\r\n");
-            } catch (IOException var4) {
-                return false;
-            }
-        }
-
-        try {
-            this.writer.write(content);
-            this.writer.flush();
-            return true;
-        } catch (IOException var3) {
-            return false;
-        }
-    }
-
-    public synchronized String readLine() {
-        if (this.writer != null) {
-            this.close();
-        }
-
-        if (this.reader == null) {
-            File file = new File(this.filePath);
-            if (file.exists()) {
-                try {
-                    InputStreamReader streamReader = new InputStreamReader(new FileInputStream(file));
-                    this.reader = new BufferedReader(streamReader);
-                } catch (FileNotFoundException var3) {
-                    return null;
-                }
-            }
-        }
-
-        if (this.reader != null) {
-            try {
-                return this.reader.readLine();
-            } catch (IOException var4) {
-                ;
-            }
-        }
-
-        return null;
-    }
-
-    public synchronized void close() {
-        if (this.writer != null) {
-            try {
-                this.writer.close();
-            } catch (IOException var5) {
-                ;
-            } finally {
-                this.writer = null;
-            }
-        }
-
-    }
-
-    public synchronized void delete() {
-        if (this.writer != null) {
-            try {
-                this.writer.close();
-            } catch (IOException var14) {
-                ;
-            } finally {
-                this.writer = null;
-            }
-        }
-
-        if (this.reader != null) {
-            try {
-                this.reader.close();
-            } catch (IOException var12) {
-                ;
-            } finally {
-                this.reader = null;
-            }
-        }
-
-        File file = new File(this.filePath);
-        if (file.exists()) {
-            file.delete();
-        }
-
-    }
-
-    public synchronized boolean isEmpty() {
-        boolean empty = this.writer == null;
-        if (!empty) {
-            File file = new File(this.filePath);
-            empty = !file.exists();
-            if (!empty) {
-                empty = file.length() == 0L;
-            }
-        }
-
-        return empty;
-    }
-}

+ 0 - 81
src/main/java/com/uas/ps/product/util/PathUtils.java

@@ -1,81 +0,0 @@
-package com.uas.ps.product.util;
-
-import com.uas.ps.core.util.ContextUtils;
-
-import java.io.File;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-
-/**
- * 路径
- *
- * @author sunyj
- * @since 2018/1/6 17:30
- */
-public class PathUtils {
-
-    private static String classPath;
-
-    private static String appPath;
-
-    private static String filePath;
-
-    /**
-     * classes文件目录
-     *
-     * @return
-     */
-    public static String getClassPath() {
-        if (classPath == null)
-            setClassPath();
-        return classPath;
-    }
-
-    /**
-     * 应用程序目录
-     *
-     * @return
-     */
-    public static String getAppPath() {
-        if (appPath == null)
-            setAppPath();
-        return appPath;
-    }
-
-    /**
-     * 日志、附件文件等存放目录,与程序同级
-     *
-     * @return
-     */
-    public static String getFilePath() {
-        if (filePath == null)
-            setFilePath();
-        return filePath;
-    }
-
-    private static void setClassPath() {
-        Class<?> objClass = ContextUtils.getApplicationContext().getClass();
-        String strRealPath = objClass.getClassLoader().getResource("").getFile();
-        try {
-            strRealPath = URLDecoder.decode(strRealPath, "UTF-8");
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace();
-        }
-        File objFile = new File(strRealPath);
-        classPath = objFile.getParent() + File.separator;
-        if (classPath.contains("/")) {
-            classPath = "/" + classPath;
-        }
-    }
-
-    private static void setAppPath() {
-        File file = new File(getClassPath());
-        appPath = file.getParent() + File.separator;
-    }
-
-    private static void setFilePath() {
-        File file = new File(getAppPath());
-        filePath = file.getParent() + File.separator;
-    }
-
-}