diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java
index 58ea2410d48..2f636bc738b 100644
--- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java
+++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BufferedResourceNode.java
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.compare.internal;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -73,18 +72,10 @@ public void commit(IProgressMonitor pm) throws CoreException {
return;
}
IResource resource = getResource();
- if (resource instanceof IFile) {
+ if (resource instanceof IFile file) {
byte[] bytes = getContent();
- try (ByteArrayInputStream is = new ByteArrayInputStream(bytes)) {
- IFile file = (IFile) resource;
- if (file.exists())
- file.setContents(is, false, true, pm);
- else
- file.create(is, false, pm);
- fDirty = false;
- } catch (IOException closeException) {
- // Silently ignored
- }
+ file.createOrReplace(bytes, false, false, true, pm);
+ fDirty = false;
}
}
}
diff --git a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java
index 340fa4e0a23..695f8692783 100644
--- a/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java
+++ b/team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceTypedElement.java
@@ -13,8 +13,6 @@
*******************************************************************************/
package org.eclipse.team.internal.ui.synchronize;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
import java.io.InputStream;
import org.eclipse.compare.ISharedDocumentAdapter;
@@ -93,16 +91,11 @@ public void commit(IProgressMonitor monitor) throws CoreException {
saveDocument(true, monitor);
} else {
IResource resource = getResource();
- if (resource instanceof IFile) {
- try (ByteArrayInputStream is = new ByteArrayInputStream(getContent())) {
- IFile file = (IFile) resource;
- if (file.exists())
- file.setContents(is, false, true, monitor);
- else
- file.create(is, false, monitor);
+ if (resource instanceof IFile file) {
+ byte[] content = getContent();
+ try {
+ file.createOrReplace(content, false, false, true, monitor);
fDirty = false;
- } catch (IOException closeException) {
- // ignored
} finally {
fireContentChanged();
}
diff --git a/team/examples/org.eclipse.team.examples.filesystem/META-INF/MANIFEST.MF b/team/examples/org.eclipse.team.examples.filesystem/META-INF/MANIFEST.MF
index 21046477037..37f9608e6f8 100644
--- a/team/examples/org.eclipse.team.examples.filesystem/META-INF/MANIFEST.MF
+++ b/team/examples/org.eclipse.team.examples.filesystem/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.team.examples.filesystem; singleton:=true
-Bundle-Version: 3.7.400.qualifier
+Bundle-Version: 3.7.500.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.team.examples.filesystem,
diff --git a/team/examples/org.eclipse.team.examples.filesystem/pom.xml b/team/examples/org.eclipse.team.examples.filesystem/pom.xml
index ff9919dde32..108e8004d36 100644
--- a/team/examples/org.eclipse.team.examples.filesystem/pom.xml
+++ b/team/examples/org.eclipse.team.examples.filesystem/pom.xml
@@ -18,7 +18,7 @@
../../
org.eclipse.team.examples.filesystem
- 3.7.400-SNAPSHOT
+ 3.7.500-SNAPSHOT
eclipse-plugin
diff --git a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java
index 786b32ec244..0927fcf25dd 100644
--- a/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java
+++ b/team/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java
@@ -584,7 +584,7 @@ public void appendText(IFile file, String text, boolean prepend) throws CoreExce
if (!prepend) {
buffer.append(System.getProperty("line.separator") + text);
}
- file.setContents(new ByteArrayInputStream(buffer.toString().getBytes()), false, false, null);
+ file.setContents(buffer.toString().getBytes(), false, false, null);
}
public static String getFileContents(IFile file) throws IOException, CoreException {