将字节数组保存到文件
import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; /* n o w j a v a . c o m */ import java.nio.file.Paths; public class Main { public static void main(String[] args) { Path ball_path = Paths.get("C:/folder1/photos", "ball.png"); try { byte[] ballArray = Files.readAllBytes(ball_path); Files.write(ball_path.resolveSibling("bytes_to_ball.png"), ballArray); } catch (IOException e) { System.out.println(e); } } }