From 40770e8d07f967fc9a711b80258eb0ecc57e8a24 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Sun, 24 Feb 2008 05:07:26 +0000 Subject: [PATCH] MRM-709: Use commons-io instead of Plexus Utils * Using FileUtils from commons-io. git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@630589 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva-artifact-converter/pom.xml | 4 +++ .../converter/artifact/AsciiFileUtil.java | 28 +++---------------- .../artifact/LegacyToDefaultConverter.java | 10 +++---- 3 files changed, 13 insertions(+), 29 deletions(-) diff --git a/archiva-base/archiva-artifact-converter/pom.xml b/archiva-base/archiva-artifact-converter/pom.xml index e5729ae8d..24b45dcc0 100644 --- a/archiva-base/archiva-artifact-converter/pom.xml +++ b/archiva-base/archiva-artifact-converter/pom.xml @@ -28,6 +28,10 @@ Archiva Artifact Converter Converts between Legacy and Modern Layout Artifacts. + + commons-io + commons-io + org.apache.maven maven-repository-metadata diff --git a/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/AsciiFileUtil.java b/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/AsciiFileUtil.java index f155e311e..a69f2134a 100644 --- a/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/AsciiFileUtil.java +++ b/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/AsciiFileUtil.java @@ -19,13 +19,11 @@ package org.apache.maven.archiva.converter.artifact; * under the License. */ -import org.codehaus.plexus.util.IOUtil; - import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; +import org.apache.commons.io.FileUtils; + /** * AsciiFileUtil - conveinence utility for reading / writing ascii files. * @@ -45,16 +43,7 @@ public class AsciiFileUtil public static String readFile( File file ) throws IOException { - FileInputStream in = null; - try - { - in = new FileInputStream( file ); - return IOUtil.toString( in ); - } - finally - { - IOUtil.close( in ); - } + return FileUtils.readFileToString( file, null ); } /** @@ -67,15 +56,6 @@ public class AsciiFileUtil public static void writeFile( File file, String content ) throws IOException { - FileOutputStream out = null; - try - { - out = new FileOutputStream( file ); - IOUtil.copy( content, out ); - } - finally - { - IOUtil.close( out ); - } + FileUtils.writeStringToFile( file, content, null ); } } diff --git a/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverter.java b/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverter.java index abe5c3635..43b8d20d3 100644 --- a/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverter.java +++ b/archiva-base/archiva-artifact-converter/src/main/java/org/apache/maven/archiva/converter/artifact/LegacyToDefaultConverter.java @@ -19,6 +19,8 @@ package org.apache.maven.archiva.converter.artifact; * under the License. */ +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import org.apache.maven.archiva.transaction.FileTransaction; import org.apache.maven.archiva.transaction.TransactionException; import org.apache.maven.artifact.Artifact; @@ -41,8 +43,6 @@ import org.apache.maven.model.converter.PomTranslationException; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; import org.codehaus.plexus.digest.Digester; import org.codehaus.plexus.digest.DigesterException; -import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.File; @@ -275,7 +275,7 @@ public class LegacyToDefaultConverter } finally { - IOUtil.close( writer ); + IOUtils.closeQuietly( writer ); } } } @@ -411,7 +411,7 @@ public class LegacyToDefaultConverter } finally { - IOUtil.close( fileReader ); + IOUtils.closeQuietly( fileReader ); } return metadata; } @@ -583,7 +583,7 @@ public class LegacyToDefaultConverter } finally { - IOUtil.close( writer ); + IOUtils.closeQuietly( writer ); } } } -- 2.39.5