隐藏页面特效

文件拼接

import java.io.*; import java.nio.channels.FileChannel; import java.util.ArrayList; import java.util.List; public class Main { private static String FILE_PATH = "D:\\BaiduNetdiskDownload\\test"; private static String DEST_FILE_PATH = "D:\\BaiduNetdiskDownload\\3.md"; public static void main(String[] args) throws IOException { ArrayList<String> fileNames = (ArrayList<String>) getFileNames(new File(FILE_PATH), new ArrayList<>()); BufferedReader br = null; PrintWriter pw = null; try { pw = new PrintWriter(DEST_FILE_PATH); for (String fileName : fileNames) { br = new BufferedReader(new InputStreamReader(new FileInputStream(FILE_PATH + File.separator + fileName))); String line; while ((line = br.readLine()) != null) { if (line.indexOf("####") > -1) { line = line.replaceAll("####", "#####"); } else if (line.indexOf("###") > -1) { line = line.replaceAll("###", "####"); } else if (line.indexOf("##") > -1) { line = line.replaceAll("##", "###"); } else if (line.indexOf("#") > -1) { line = line.replaceAll("#", "##"); } pw.println(line); } br.close(); } } catch (FileNotFoundException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } finally { br.close(); pw.close(); } System.out.println("Hello world!"); } private static List<String> getFileNames(File file, List<String> fileNames) { File[] files = file.listFiles(); for (File f : files) { if (f.isDirectory()) { getFileNames(f, fileNames); } else { fileNames.add(f.getName()); } } return fileNames; } private void test() throws IOException { ArrayList<String> fileNames = (ArrayList<String>) getFileNames(new File(FILE_PATH), new ArrayList<>()); BufferedReader br = null; PrintWriter pw = null; FileChannel inputChannel = null; FileChannel outputChannel = null; try { outputChannel = new FileOutputStream(DEST_FILE_PATH).getChannel(); long index = 0; for (String fileName : fileNames) { inputChannel = new FileInputStream(FILE_PATH + File.separator + fileName).getChannel(); outputChannel.transferFrom(inputChannel, index, inputChannel.size()); index += inputChannel.size(); } } catch (FileNotFoundException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } finally { inputChannel.close(); outputChannel.close(); } System.out.println("Hello world!"); } }

__EOF__

本文作者FigSprite
本文链接https://www.cnblogs.com/figsprite/p/17589703.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   FigSprite  阅读(19)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端
点击右上角即可分享
微信分享提示