文件流的使用(上传图片例子) 发表于 2018-07-19 分类于 Java 1.文件流的使用1.1读取文件,转化成流获取当前路径,创建file,把file写进流里,建立byte数组,直接写进流里 123456file file =new File(String path);if(!file.exist()){ return;}inputSteam input=new inputstream(file); int datLength=fis.available(); //文件的长度 获取文件的长度直接写进byte数组 1234byte[] ecgByte = new byte[datLength];while(readLength=fis.read(ecgByte)) != -1){ //如果不是最后一个就一直读 fos.write(ecgByte);} 上传图片看工具包upserver