User: rinkrank
Date: 02/03/25 16:01:18
Modified: core/src/xdoclet/util FileManager.java
Log:
-Added Field and Constructor-level support to info/todo
-Restructured layout for todo task (with gifs)
-Added a method to FileManager for writing out binary files from jar resources
-Some ArrayList -> List refactorings
Revision Changes Path
1.7 +26 -12 xdoclet/core/src/xdoclet/util/FileManager.java
Index: FileManager.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/util/FileManager.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -r1.6 -r1.7
--- FileManager.java 14 Mar 2002 20:29:28 -0000 1.6
+++ FileManager.java 26 Mar 2002 00:01:18 -0000 1.7
@@ -1,8 +1,13 @@
package xdoclet.util;
+import java.io.InputStream;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
import java.io.FileNotFoundException;
+import java.io.File;
+import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
@@ -15,7 +20,7 @@
*
* @author Ara Abrahamian ([EMAIL PROTECTED])
* @created Aug 5, 2001
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
* @todo Deal with Translator.getString()'s exception better (throw it so
* the build stops?) in getFileContent(String)
*/
@@ -34,7 +39,7 @@
try
{
- java.io.InputStream is = null;
+ InputStream is = null;
if( "file".equals( url.getProtocol() ) )
{
@@ -45,17 +50,9 @@
is = url.openStream();
}
- java.io.InputStream in = new BufferedInputStream( is );
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(
is.available() );
- ByteArrayOutputStream baos = new ByteArrayOutputStream(
in.available() );
-
- byte[] b = new byte[in.available()];
- int len;
-
- while( in.available() > 0 && ( len = in.read( b ) ) != -1 )
- {
- baos.write( b, 0, len );
- }
+ pump( is, baos );
content = new String( baos.toByteArray() );
urlCache.put( url, content );
@@ -79,5 +76,22 @@
}
return null;
}
+ }
+
+ private static void pump( InputStream is, OutputStream os ) throws IOException
{
+ BufferedInputStream bis = new BufferedInputStream( is );
+ byte[] b = new byte[is.available()];
+ int len;
+ while( is.available() > 0 && ( len = is.read( b ) ) != -1 )
+ {
+ os.write( b, 0, len );
+ }
+ }
+
+ public static synchronized void writeURLContent( URL url, File destination )
throws IOException {
+ FileOutputStream fos = new FileOutputStream(destination);
+ pump(url.openStream(), fos);
+ fos.flush();
+ fos.close();
}
}
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel