java怎么读取某个文本文件的内容写入到另一个文本文件

如题所述

/** * 读出写出 * @param oldFileName 源文件 * @param newFileName 新文件 * @throws IOException */public static void testRead(String oldFileName,String newFileName) throws IOException{ FileOutputStream fos=new FileOutputStream(new File(newFileName)); RandomAccessFile raf=new RandomAccessFile(new File(oldFileName), "rw"); fos.write(raf.read(new byte[8])); fos.flush(); fos.close(); raf.close();} public static void fileWrite() throws FileNotFoundException, IOException { testRead("G:/森云/测试文件1。txt","G:/newFile.txt");}
温馨提示:答案为网友推荐,仅供参考
相似回答