同步操作将从 Rainy/DocSys 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package util;import java.io.*;/*** 文件操作代码** @author cn.outofmemory* @date 2013年1月7日*/public class FileUtils {// 验证字符串是否为正确路径名的正则public static String matches = "[A-Za-z]:\\\\[^:?\"><*]*";public final static String crlf = System.getProperty("line.separator");/*** 将文本文件中的内容读入到buffer中** @param buffer* buffer* @param filePath* 文件路径* @throws IOException* 异常* @author cn.outofmemory* @date 2013年1月7日*/public static void readToBuffer(StringBuffer buffer, String filePath)throws IOException {InputStream is = new FileInputStream(filePath);String line; // 用来保存每行读取的内容BufferedReader reader = new BufferedReader(new InputStreamReader(is));line = reader.readLine(); // 读取第一行while (line != null) { // 如果 line 为空说明读完了buffer.append(line); // 将读到的内容添加到 buffer 中buffer.append(crlf); // 添加换行符line = reader.readLine(); // 读取下一行}reader.close();is.close();}/*** 读取文本文件内容** @param filePath* 文件所在路径* @return 文本内容* @throws IOException* 异常* @author cn.outofmemory* @date 2013年1月7日*/public static String readText(String filePath) throws IOException {StringBuffer sb = new StringBuffer();FileUtils.readToBuffer(sb, filePath);return sb.toString();}public static void WriteText(String filePath, String content) {File file = new File(filePath);try (FileOutputStream fop = new FileOutputStream(file)) {// if file doesn't exists, then create itif (!file.exists()) {file.createNewFile();}// get the content in bytesbyte[] contentInBytes = content.getBytes();fop.write(contentInBytes);fop.flush();fop.close();} catch (IOException e) {e.printStackTrace();}}public static String getPrefix(File file) {String fileName = file.getName();int index = fileName.lastIndexOf(".") + 1;if( 0 == index){return "";}else{return fileName.substring(index);}}// 删除文件public static boolean deleteFile(String sPath) {File file = new File(sPath);if (file.exists() && file.isFile()) {file.delete();return true;}return false;}// 子文件的个数public static int countFiles(String path) {File folder = new File(path);if ( folder.isDirectory() ){int num = 0;File[] flist = folder.listFiles();for(int i =0 ; i<flist.length ; i++){if(flist[i].isFile()){num += 1;}}return num;}else {return 0;}}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。