java io本地文件读写积累 未完待续...

来源:互联网 发布:康丝数据 编辑:程序博客网 时间:2024/05/24 00:02

一、写入本地文件(+ 创建文件路径)

/** *  创建文件夹 * @param filepath 文件夹路径 * @param filename  文件名 * @return */public static String createDir(String filepath, String filename) {File file = new File(filepath);String path = "";if (!file.exists()) {boolean flag = file.mkdirs();}//创建文件path = createFile(filepath+filename);return path;}/** * 创建文件 * @param path 全路径 * @return */public static String createFile(String path) {File file = new File(path);if (!file.exists()) {try {file.createNewFile();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();
      return null;

 }}return path;}


原创粉丝点击