PDF ファイルをある場所から別の場所にコピーしようとしていますが、次のコードを実行すると、PDF を開くことができません (次のエラーが表示されます)。
このドキュメントを開くときにエラーが発生しました。ファイルが破損しており、修復できませんでした
public class BinaryFileTransfer {
private static String INPUT_FILE = "C:\\Users\\sashwat\\Desktop\\a.pdf";
private static String OUTPUT_FILE = "C:\\Users\\sashwat\\Desktop\\a-copy.pdf";
public static void main(String args[]) throws Exception {
InputStream is = new BufferedInputStream(new FileInputStream(INPUT_FILE));
OutputStream wos = new BufferedOutputStream(new FileOutputStream(OUTPUT_FILE));
int len = 0;
byte[] brr = new byte[1000];
while ((len = is.read(brr)) != -1) {
wos.write(brr, 0, len);
}
}
}
誰かが私が間違っていることについて私を助けることができますか?