diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java index 2bda76c32..2147a2e5c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.api; import java.io.File; +import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; @@ -147,10 +148,14 @@ public ApplyResult call() throws GitAPIException, PatchFormatException, case COPY: f = getFile(fh.getOldPath(), false); byte[] bs = IO.readFully(f); - FileWriter fw = new FileWriter(getFile(fh.getNewPath(), + FileOutputStream fos = new FileOutputStream(getFile( + fh.getNewPath(), true)); - fw.write(new String(bs)); - fw.close(); + try { + fos.write(bs); + } finally { + fos.close(); + } } r.addUpdatedFile(f); }