From: Brett Porter Date: Wed, 7 Jun 2006 04:38:04 +0000 (+0000) Subject: clean up, use IOUtil X-Git-Tag: archiva-0.9-alpha-1~848 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c36f7f427ccd6d00ef30fc5a69ef34f48782375d;p=archiva.git clean up, use IOUtil git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@412289 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/EclipseRepositoryIndex.java b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/EclipseRepositoryIndex.java index e4ad5ab00..f96c3032e 100644 --- a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/EclipseRepositoryIndex.java +++ b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/EclipseRepositoryIndex.java @@ -27,6 +27,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.repository.digest.Digester; import org.codehaus.plexus.util.FileUtils; +import org.codehaus.plexus.util.IOUtil; import java.io.File; import java.io.FileInputStream; @@ -184,26 +185,7 @@ public class EclipseRepositoryIndex { for ( int i = 0; i < files.length; i++ ) { - ZipEntry e = new ZipEntry( files[i].getName() ); - zos.putNextEntry( e ); - - FileInputStream is = new FileInputStream( files[i] ); - byte[] buf = new byte[4096]; - int n; - try - { - while ( ( n = is.read( buf ) ) > 0 ) - { - zos.write( buf, 0, n ); - } - } - finally - { - is.close(); - } - zos.flush(); - - zos.closeEntry(); + writeFile( zos, files[i] ); } } finally @@ -214,6 +196,26 @@ public class EclipseRepositoryIndex return outputFile; } + private static void writeFile( ZipOutputStream zos, File file ) + throws IOException + { + ZipEntry e = new ZipEntry( file.getName() ); + zos.putNextEntry( e ); + + FileInputStream is = new FileInputStream( file ); + try + { + IOUtil.copy( is, zos ); + } + finally + { + is.close(); + } + zos.flush(); + + zos.closeEntry(); + } + /** * @see AbstractRepositoryIndex#deleteIfIndexed(Object) */ @@ -257,7 +259,7 @@ public class EclipseRepositoryIndex /** * Class used to analyze the lucene index */ - private class EclipseIndexAnalyzer + private static class EclipseIndexAnalyzer extends Analyzer { private Analyzer defaultAnalyzer; @@ -267,7 +269,7 @@ public class EclipseRepositoryIndex * * @param defaultAnalyzer the analyzer to use as default for the general fields of the artifact indeces */ - public EclipseIndexAnalyzer( Analyzer defaultAnalyzer ) + EclipseIndexAnalyzer( Analyzer defaultAnalyzer ) { this.defaultAnalyzer = defaultAnalyzer; } @@ -294,33 +296,33 @@ public class EclipseRepositoryIndex return tokenStream; } + } + /** + * Class used to tokenize the eclipse index + */ + private static class EclipseIndexTokenizer + extends CharTokenizer + { /** - * Class used to tokenize the eclipse index + * Constructor with the required reader to the index stream + * + * @param reader the Reader object of the index stream */ - private class EclipseIndexTokenizer - extends CharTokenizer + EclipseIndexTokenizer( Reader reader ) { - /** - * Constructor with the required reader to the index stream - * - * @param reader the Reader object of the index stream - */ - EclipseIndexTokenizer( Reader reader ) - { - super( reader ); - } + super( reader ); + } - /** - * method that lucene calls to check tokenization of a stream character - * - * @param character char currently being processed - * @return true if the char is a token, false if the char is a stop char - */ - protected boolean isTokenChar( char character ) - { - return true; - } + /** + * method that lucene calls to check tokenization of a stream character + * + * @param character char currently being processed + * @return true if the char is a token, false if the char is a stop char + */ + protected boolean isTokenChar( char character ) + { + return true; } } }