[R-Help] Remove DateStream.copy to avoid misuse
Change-Id: I301f7343ea6ffa5575b02d0a7cb80234d6036531
diff --git a/rhelp/org.eclipse.statet.rhelp.core/src/org/eclipse/statet/internal/rhelp/core/DataStream.java b/rhelp/org.eclipse.statet.rhelp.core/src/org/eclipse/statet/internal/rhelp/core/DataStream.java
index e479a75..cfbe769 100644
--- a/rhelp/org.eclipse.statet.rhelp.core/src/org/eclipse/statet/internal/rhelp/core/DataStream.java
+++ b/rhelp/org.eclipse.statet.rhelp.core/src/org/eclipse/statet/internal/rhelp/core/DataStream.java
@@ -39,7 +39,7 @@
public final class DataStream implements AutoCloseable {
- private static final ThreadLocal<DataStream> INSTANCES= new ThreadLocal<DataStream>() {
+ private static final ThreadLocal<DataStream> INSTANCES= new ThreadLocal<>() {
@Override
protected DataStream initialValue() {
@@ -62,14 +62,6 @@
return io;
}
- public static void copy(final InputStream in, final OutputStream out) throws IOException {
- final byte[] buffer= INSTANCES.get().ba;
- int n;
- while ((n = in.read(buffer, 0, buffer.length)) != -1) {
- out.write(buffer, 0, n);
- }
- }
-
public static long decodeLong(final byte[] ba) {
return (((long) (ba[0] & 0xff) << 56) |
diff --git a/rhelp/org.eclipse.statet.rhelp.core/src/org/eclipse/statet/internal/rhelp/core/SerUtil.java b/rhelp/org.eclipse.statet.rhelp.core/src/org/eclipse/statet/internal/rhelp/core/SerUtil.java
index 7358757..aebde9e 100644
--- a/rhelp/org.eclipse.statet.rhelp.core/src/org/eclipse/statet/internal/rhelp/core/SerUtil.java
+++ b/rhelp/org.eclipse.statet.rhelp.core/src/org/eclipse/statet/internal/rhelp/core/SerUtil.java
@@ -18,7 +18,6 @@
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
@@ -154,8 +153,8 @@
try {
final Path directory= getIndexDirectoryChecked(rEnvConfig);
final Path newFile= directory.resolve(RHELP_SER_FILE + ".new"); //$NON-NLS-1$
- Files.deleteIfExists(newFile);
+ Files.deleteIfExists(newFile);
try (final DataStream out= DataStream.get(new BufferedOutputStream(
Files.newOutputStream(newFile, StandardOpenOption.CREATE_NEW) ))) {
save(help, out, COMPRESS);
@@ -186,12 +185,8 @@
try {
final Path directory= getIndexDirectoryChecked(rEnvConfig);
final Path newFile= directory.resolve(RHELP_SER_FILE + ".new"); //$NON-NLS-1$
- Files.deleteIfExists(newFile);
- try (final OutputStream out= new BufferedOutputStream(
- Files.newOutputStream(newFile, StandardOpenOption.CREATE_NEW) )) {
- DataStream.copy(in, out);
- }
+ Files.copy(in, newFile, StandardCopyOption.REPLACE_EXISTING);
synchronized (controller.getFileLock()) {
if (!controller.shouldSave()) {