Java IO流读写照片(字节流)

简单的文件读写

 	public static void main(String[] args) {
		String inFile = "D:\\Program Files (x86)\\kqUpJPG\\1.jpg";
		String outFile = "D:\\Program Files (x86)\\2.jpg";
		FileInputStream input = null;
		FileOutputStream out = null;
		try {
			input = new FileInputStream(inFile);
			out = new FileOutputStream(outFile);
			byte[] b = new byte[input.available()];
			int len ;
			while((len = input.read(b)) != -1) {
				out.write(b, 0, len);
			}
			input.close();
			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

你可能感兴趣的:(后端,java)