cleaned up some code - replaced a bunch of copy loops with calls to the new

IOUtil class methods, added some javadocs to IOUtil, StringUtil, and
AnyCharMatcher
This commit is contained in:
Eric J. Bowersox
2001-10-31 19:38:40 +00:00
parent f1584f3f4a
commit 597ebadf35
10 changed files with 391 additions and 98 deletions

View File

@@ -555,7 +555,7 @@ public class RenderConfig implements ColorSelectors
synchronized String loadStyleSheetData() throws IOException
{
// Load the stylesheet data.
StringBuffer raw_data = IOUtil.load(stylesheet);
StringBuffer raw_data = IOUtil.loadText(stylesheet);
stylesheet_time = stylesheet.lastModified();
// Set up the replacements map to replace the various parameters.

View File

@@ -23,6 +23,7 @@ import java.text.DateFormat;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.*;
import com.silverwrist.util.IOUtil;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.core.DataException;
import com.silverwrist.venice.core.IDUtils;
@@ -462,16 +463,7 @@ public class RenderData implements ColorSelectors
response.setHeader("Content-Disposition","attachment; filename=\"" + filename + "\";");
// Copy the contents of the "data" stream to the output.
ServletOutputStream stm = response.getOutputStream();
byte[] buffer = new byte[4096];
int rd = data.read(buffer);
while (rd>=0)
{ // simple read-write loop to shove data out the door
if (rd>0)
stm.write(buffer,0,rd);
rd = data.read(buffer);
} // end while
IOUtil.copy(data,response.getOutputStream());
} // end sendBinaryData

View File

@@ -18,6 +18,7 @@
package com.silverwrist.venice.servlets.format;
import java.io.*;
import com.silverwrist.util.IOUtil;
import com.silverwrist.util.cachemap.CacheMap;
public class StaticRender implements ContentRender
@@ -94,21 +95,10 @@ public class StaticRender implements ContentRender
} // end if
// Read in the whole thing.
StringBuffer raw_file = new StringBuffer();
StringBuffer raw_file;
try
{ // read in from the file
FileReader rdr = new FileReader(real_path);
char[] buffer = new char[4096];
int rd = rdr.read(buffer);
while (rd>=0)
{ // read in the raw characters
if (rd>0)
raw_file.append(buffer,0,rd);
rd = rdr.read(buffer);
} // end while
rdr.close();
raw_file = IOUtil.loadText(new File(real_path));
} // end try
catch (IOException ioe)