You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by cm...@apache.org on 2003/05/06 12:43:37 UTC
cvs commit: jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/util ResourceUtils.java
cmlenz 2003/05/06 03:43:36
Modified: integration/ant/src/java/org/apache/cactus/integration/ant/util
Tag: CACTUS_14_ANT_BRANCH ResourceUtils.java
Log:
Make copyResource() without a FilterChain argument perform an exact binary copy.
Otherwise, a new line is appended to text files that do not originally contain one, which broke the jspRedirector.jsp
Revision Changes Path
No revision
No revision
1.2.2.3 +34 -3 jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/util/Attic/ResourceUtils.java
Index: ResourceUtils.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/util/Attic/ResourceUtils.java,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -u -r1.2.2.2 -r1.2.2.3
--- ResourceUtils.java 1 May 2003 12:09:32 -0000 1.2.2.2
+++ ResourceUtils.java 6 May 2003 10:43:36 -0000 1.2.2.3
@@ -59,10 +59,12 @@
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.OutputStream;
import java.net.URL;
import java.util.Enumeration;
import java.util.Vector;
@@ -109,8 +111,37 @@
File theDestFile)
throws IOException
{
- copyResource(theProject, theResourceName, theDestFile,
- new FilterChain());
+ InputStream in =
+ ResourceUtils.class.getResourceAsStream(theResourceName);
+ if (in == null)
+ {
+ throw new IOException("Resource '" + theResourceName
+ + "' not found");
+ }
+
+ OutputStream out = null;
+ try
+ {
+ out = new FileOutputStream(theDestFile);
+
+ byte buf[] = new byte[4096];
+ int numBytes = 0;
+ while ((numBytes = in.read(buf)) > 0)
+ {
+ out.write(buf, 0, numBytes);
+ }
+ }
+ finally
+ {
+ if (in != null)
+ {
+ in.close();
+ }
+ if (out != null)
+ {
+ out.close();
+ }
+ }
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org