1.简单案例 public class AA{ //OutputStream 将我们定义好的数据放置到我们的目标文件中 private static void testMethod1(String path) throws IOException{ //1.打开文件输出流,流的目的地是指定的文件 FileOutputStream fos=new FileOutputStream(path, true); //2.通过流文件写数据 byte[] byt="java".getBytes(); fos.write(byt); //3.关闭流文件 fos.close(); } public static void main(String[] args) throws IOException { try { testMethod1("C:\\caicai2.txt"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } 2.将文件进行拷贝 import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class CC { //拷贝文件的一般写法,需要添加异常捕获并关闭IO流的操作 //方法作用:将源文件的数据拷贝目标文件夹的位置 public static void copyMethod(String srcPath,String destPath) throws