maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject cvs commit: maven-components/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources ResourcesMojo.java
Date Wed, 03 Nov 2004 03:43:31 GMT
jdcasey     2004/11/02 19:43:31

  Modified:    maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources
                        ResourcesMojo.java
  Log:
  o Changed fileCopy process to use byte arrays and ByteArrayOutputStream rather than String/StringBuffer
to accommodate binary [test] resources.
  
  Revision  Changes    Path
  1.10      +10 -10    maven-components/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java
  
  Index: ResourcesMojo.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ResourcesMojo.java	20 Jun 2004 14:03:44 -0000	1.9
  +++ ResourcesMojo.java	3 Nov 2004 03:43:31 -0000	1.10
  @@ -24,6 +24,7 @@
   
   import org.codehaus.plexus.util.FileUtils;
   
  +import java.io.ByteArrayOutputStream;
   import java.io.File;
   import java.io.FileInputStream;
   import java.io.FileOutputStream;
  @@ -86,7 +87,7 @@
               {
                   destinationFile.getParentFile().mkdirs();
               }
  -
  +            
               fileCopy( resourceEntry.getSource(), destinationFile.getPath() );
           }
       }
  @@ -169,35 +170,34 @@
           return sb.toString();
       }
   
  -    public static String fileRead( String fileName ) throws IOException
  +    public static byte[] fileRead( String fileName ) throws IOException
       {
  -        StringBuffer buf = new StringBuffer();
  -
           FileInputStream in = new FileInputStream( fileName );
  +        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
   
           int count;
           byte[] b = new byte[512];
           while ( ( count = in.read( b ) ) > 0 )  // blocking read
           {
  -            buf.append( new String( b, 0, count ) );
  +            buffer.write(b, 0, count);
           }
   
           in.close();
   
  -        return buf.toString();
  +        return buffer.toByteArray();
       }
   
  -    public static void fileWrite( String fileName, String data ) throws Exception
  +    public static void fileWrite( String fileName, byte[] data ) throws Exception
       {
           FileOutputStream out = new FileOutputStream( fileName );
  -        out.write( data.getBytes() );
  +        out.write( data );
           out.close();
       }
   
       public static void fileCopy( String inFileName, String outFileName ) throws
           Exception
       {
  -        String content = fileRead( inFileName );
  +        byte[] content = fileRead( inFileName );
           fileWrite( outFileName, content );
       }
   
  
  
  

Mime
View raw message