You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ba...@apache.org on 2003/12/30 08:06:47 UTC
cvs commit: jakarta-commons-sandbox/io/src/test/org/apache/commons/io IOUtilsTestCase.java
bayard 2003/12/29 23:06:46
Modified: io/src/java/org/apache/commons/io IOUtils.java
io/src/test/org/apache/commons/io IOUtilsTestCase.java
Log:
removed deprecated methods from IOUtils
Revision Changes Path
1.10 +9 -373 jakarta-commons-sandbox/io/src/java/org/apache/commons/io/IOUtils.java
Index: IOUtils.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/IOUtils.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- IOUtils.java 30 Dec 2003 06:50:16 -0000 1.9
+++ IOUtils.java 30 Dec 2003 07:06:46 -0000 1.10
@@ -242,171 +242,6 @@
}
}
- ///////////////////////////////////////////////////////////////
- // Core copy methods
- ///////////////////////////////////////////////////////////////
-
- /**
- * Copy bytes from an <code>InputStream</code> to an <code>OutputStream</code>.
- * @param input the <code>InputStream</code> to read from
- * @param output the <code>OutputStream</code> to write to
- * @return the number of bytes copied
- * @throws IOException In case of an I/O problem
- * @deprecated Replaced by {@link CopyUtils#copy(InputStream, OutputStream)}
- */
- public static int copy( InputStream input, OutputStream output )
- throws IOException
- {
- return copy( input, output, DEFAULT_BUFFER_SIZE );
- }
-
- /**
- * Copy bytes from an <code>InputStream</code> to an <code>OutputStream</code>.
- * @param input the <code>InputStream</code> to read from
- * @param output the <code>OutputStream</code> to write to
- * @param bufferSize Size of internal buffer to use.
- * @return the number of bytes copied
- * @throws IOException In case of an I/O problem
- * @deprecated Replaced by {@link CopyUtils#copy(InputStream, OutputStream, int)}
- */
- public static int copy( InputStream input,
- OutputStream output,
- int bufferSize )
- throws IOException
- {
- byte[] buffer = new byte[ bufferSize ];
- int count = 0;
- int n = 0;
- while( -1 != ( n = input.read( buffer ) ) )
- {
- output.write( buffer, 0, n );
- count += n;
- }
- return count;
- }
-
- /**
- * Copy chars from a <code>Reader</code> to a <code>Writer</code>.
- * @param input the <code>Reader</code> to read from
- * @param output the <code>Writer</code> to write to
- * @return the number of characters copied
- * @throws IOException In case of an I/O problem
- * @deprecated Replaced by {@link CopyUtils#copy(Reader, Writer)}
- */
- public static int copy( Reader input, Writer output )
- throws IOException
- {
- return copy( input, output, DEFAULT_BUFFER_SIZE );
- }
-
- /**
- * Copy chars from a <code>Reader</code> to a <code>Writer</code>.
- * @param input the <code>Reader</code> to read from
- * @param output the <code>Writer</code> to write to
- * @param bufferSize Size of internal buffer to use.
- * @return the number of characters copied
- * @throws IOException In case of an I/O problem
- * @deprecated Replaced by {@link CopyUtils#copy(Reader, Writer, int)}
- */
- public static int copy( Reader input, Writer output, int bufferSize )
- throws IOException
- {
- char[] buffer = new char[ bufferSize ];
- int count = 0;
- int n = 0;
- while( -1 != ( n = input.read( buffer ) ) )
- {
- output.write( buffer, 0, n );
- count += n;
- }
- return count;
- }
-
- ///////////////////////////////////////////////////////////////
- // Derived copy methods
- // InputStream -> *
- ///////////////////////////////////////////////////////////////
-
-
- ///////////////////////////////////////////////////////////////
- // InputStream -> Writer
-
- /**
- * Copy and convert bytes from an <code>InputStream</code> to chars on a
- * <code>Writer</code>.
- * The platform's default encoding is used for the byte-to-char conversion.
- * @param input the <code>InputStream</code> to read from
- * @param output the <code>Writer</code> to write to
- * @throws IOException In case of an I/O problem
- * @deprecated Replaced by {@link CopyUtils#copy(InputStream, Writer)}
- */
- public static void copy( InputStream input, Writer output )
- throws IOException
- {
- copy( input, output, DEFAULT_BUFFER_SIZE );
- }
-
- /**
- * Copy and convert bytes from an <code>InputStream</code> to chars on a
- * <code>Writer</code>.
- * The platform's default encoding is used for the byte-to-char conversion.
- * @param input the <code>InputStream</code> to read from
- * @param output the <code>Writer</code> to write to
- * @param bufferSize Size of internal buffer to use.
- * @throws IOException In case of an I/O problem
- * @deprecated Replaced by {@link CopyUtils#copy(InputStream, Writer, int)}
- */
- public static void copy( InputStream input, Writer output, int bufferSize )
- throws IOException
- {
- InputStreamReader in = new InputStreamReader( input );
- copy( in, output, bufferSize );
- }
-
- /**
- * Copy and convert bytes from an <code>InputStream</code> to chars on a
- * <code>Writer</code>, using the specified encoding.
- * @param input the <code>InputStream</code> to read from
- * @param output the <code>Writer</code> to write to
- * @param encoding The name of a supported character encoding. See the
- * <a href="http://www.iana.org/assignments/character-sets">IANA
- * Charset Registry</a> for a list of valid encoding types.
- * @throws IOException In case of an I/O problem
- * @deprecated Replaced by {@link CopyUtils#copy(InputStream, Writer, String)}
- */
- public static void copy( InputStream input, Writer output, String encoding )
- throws IOException
- {
- InputStreamReader in = new InputStreamReader( input, encoding );
- copy( in, output );
- }
-
- /**
- * Copy and convert bytes from an <code>InputStream</code> to chars on a
- * <code>Writer</code>, using the specified encoding.
- * @param input the <code>InputStream</code> to read from
- * @param output the <code>Writer</code> to write to
- * @param encoding The name of a supported character encoding. See the
- * <a href="http://www.iana.org/assignments/character-sets">IANA
- * Charset Registry</a> for a list of valid encoding types.
- * @param bufferSize Size of internal buffer to use.
- * @throws IOException In case of an I/O problem
- * @deprecated Replaced by {@link CopyUtils#copy(InputStream, Writer, String, int)}
- */
- public static void copy( InputStream input,
- Writer output,
- String encoding,
- int bufferSize )
- throws IOException
- {
- InputStreamReader in = new InputStreamReader( input, encoding );
- copy( in, output, bufferSize );
- }
-
-
- ///////////////////////////////////////////////////////////////
- // InputStream -> String
-
/**
* Get the contents of an <code>InputStream</code> as a String.
* The platform's default encoding is used for the byte-to-char conversion.
@@ -432,7 +267,7 @@
throws IOException
{
StringWriter sw = new StringWriter();
- copy( input, sw, bufferSize );
+ CopyUtils.copy( input, sw, bufferSize );
return sw.toString();
}
@@ -467,7 +302,7 @@
throws IOException
{
StringWriter sw = new StringWriter();
- copy( input, sw, encoding, bufferSize );
+ CopyUtils.copy( input, sw, encoding, bufferSize );
return sw.toString();
}
@@ -497,7 +332,7 @@
throws IOException
{
ByteArrayOutputStream output = new ByteArrayOutputStream();
- copy( input, output, bufferSize );
+ CopyUtils.copy( input, output, bufferSize );
return output.toByteArray();
}
@@ -508,41 +343,6 @@
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
- // Reader -> OutputStream
- /**
- * Serialize chars from a <code>Reader</code> to bytes on an <code>OutputStream</code>, and
- * flush the <code>OutputStream</code>.
- * @param input the <code>Reader</code> to read from
- * @param output the <code>OutputStream</code> to write to
- * @throws IOException In case of an I/O problem
- * @deprecated Replaced by {@link CopyUtils#copy(Reader, OutputStream)}
- */
- public static void copy( Reader input, OutputStream output )
- throws IOException
- {
- copy( input, output, DEFAULT_BUFFER_SIZE );
- }
-
- /**
- * Serialize chars from a <code>Reader</code> to bytes on an <code>OutputStream</code>, and
- * flush the <code>OutputStream</code>.
- * @param input the <code>Reader</code> to read from
- * @param output the <code>OutputStream</code> to write to
- * @param bufferSize Size of internal buffer to use.
- * @throws IOException In case of an I/O problem
- * @deprecated Replaced by {@link CopyUtils#copy(Reader, OutputStream, int)}
- */
- public static void copy( Reader input, OutputStream output, int bufferSize )
- throws IOException
- {
- OutputStreamWriter out = new OutputStreamWriter( output );
- copy( input, out, bufferSize );
- // NOTE: Unless anyone is planning on rewriting OutputStreamWriter, we have to flush
- // here.
- out.flush();
- }
-
- ///////////////////////////////////////////////////////////////
// Reader -> String
/**
* Get the contents of a <code>Reader</code> as a String.
@@ -567,7 +367,7 @@
throws IOException
{
StringWriter sw = new StringWriter();
- copy( input, sw, bufferSize );
+ CopyUtils.copy( input, sw, bufferSize );
return sw.toString();
}
@@ -597,7 +397,7 @@
throws IOException
{
ByteArrayOutputStream output = new ByteArrayOutputStream();
- copy( input, output, bufferSize );
+ CopyUtils.copy( input, output, bufferSize );
return output.toByteArray();
}
@@ -609,61 +409,6 @@
///////////////////////////////////////////////////////////////
- // String -> OutputStream
-
- /**
- * Serialize chars from a <code>String</code> to bytes on an <code>OutputStream</code>, and
- * flush the <code>OutputStream</code>.
- * @param input the <code>String</code> to read from
- * @param output the <code>OutputStream</code> to write to
- * @throws IOException In case of an I/O problem
- * @deprecated Replaced by {@link CopyUtils#copy(String, OutputStream)}
- */
- public static void copy( String input, OutputStream output )
- throws IOException
- {
- copy( input, output, DEFAULT_BUFFER_SIZE );
- }
-
- /**
- * Serialize chars from a <code>String</code> to bytes on an <code>OutputStream</code>, and
- * flush the <code>OutputStream</code>.
- * @param input the <code>String</code> to read from
- * @param output the <code>OutputStream</code> to write to
- * @param bufferSize Size of internal buffer to use.
- * @throws IOException In case of an I/O problem
- * @deprecated Replaced by {@link CopyUtils#copy(String, OutputStream, int)}
- */
- public static void copy( String input, OutputStream output, int bufferSize )
- throws IOException
- {
- StringReader in = new StringReader( input );
- OutputStreamWriter out = new OutputStreamWriter( output );
- copy( in, out, bufferSize );
- // NOTE: Unless anyone is planning on rewriting OutputStreamWriter, we have to flush
- // here.
- out.flush();
- }
-
-
-
- ///////////////////////////////////////////////////////////////
- // String -> Writer
-
- /**
- * Copy chars from a <code>String</code> to a <code>Writer</code>.
- * @param input the <code>String</code> to read from
- * @param output the <code>Writer</code> to write to
- * @throws IOException In case of an I/O problem
- * @deprecated Replaced by {@link CopyUtils#copy(String, Writer)}
- */
- public static void copy( String input, Writer output )
- throws IOException
- {
- output.write( input );
- }
-
- ///////////////////////////////////////////////////////////////
// String -> byte[]
/**
* Get the contents of a <code>String</code> as a <code>byte[]</code>.
@@ -688,7 +433,7 @@
throws IOException
{
ByteArrayOutputStream output = new ByteArrayOutputStream();
- copy( input, output, bufferSize );
+ CopyUtils.copy( input, output, bufferSize );
return output.toByteArray();
}
@@ -699,83 +444,6 @@
// byte[] -> *
///////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////
- // byte[] -> Writer
-
- /**
- * Copy and convert bytes from a <code>byte[]</code> to chars on a
- * <code>Writer</code>.
- * The platform's default encoding is used for the byte-to-char conversion.
- * @param input the byte array to read from
- * @param output the <code>Writer</code> to write to
- * @throws IOException In case of an I/O problem
- * @deprecated Replaced by {@link CopyUtils#copy(byte[], Writer)}
- */
- public static void copy( byte[] input, Writer output )
- throws IOException
- {
- copy( input, output, DEFAULT_BUFFER_SIZE );
- }
-
- /**
- * Copy and convert bytes from a <code>byte[]</code> to chars on a
- * <code>Writer</code>.
- * The platform's default encoding is used for the byte-to-char conversion.
- * @param input the byte array to read from
- * @param output the <code>Writer</code> to write to
- * @param bufferSize Size of internal buffer to use.
- * @throws IOException In case of an I/O problem
- * @deprecated Replaced by {@link CopyUtils#copy(byte[], Writer, int)}
- */
- public static void copy( byte[] input, Writer output, int bufferSize )
- throws IOException
- {
- ByteArrayInputStream in = new ByteArrayInputStream( input );
- copy( in, output, bufferSize );
- }
-
- /**
- * Copy and convert bytes from a <code>byte[]</code> to chars on a
- * <code>Writer</code>, using the specified encoding.
- * @param input the byte array to read from
- * @param output the <code>Writer</code> to write to
- * @param encoding The name of a supported character encoding. See the
- * <a href="http://www.iana.org/assignments/character-sets">IANA
- * Charset Registry</a> for a list of valid encoding types.
- * @throws IOException In case of an I/O problem
- * @deprecated Replaced by {@link CopyUtils#copy(byte[], Writer, String)}
- */
- public static void copy( byte[] input, Writer output, String encoding )
- throws IOException
- {
- ByteArrayInputStream in = new ByteArrayInputStream( input );
- copy( in, output, encoding );
- }
-
- /**
- * Copy and convert bytes from a <code>byte[]</code> to chars on a
- * <code>Writer</code>, using the specified encoding.
- * @param input the byte array to read from
- * @param output the <code>Writer</code> to write to
- * @param encoding The name of a supported character encoding. See the
- * <a href="http://www.iana.org/assignments/character-sets">IANA
- * Charset Registry</a> for a list of valid encoding types.
- * @param bufferSize Size of internal buffer to use.
- * @throws IOException In case of an I/O problem
- * @deprecated Replaced by {@link CopyUtils#copy(byte[], Writer, String, int)}
- */
- public static void copy( byte[] input,
- Writer output,
- String encoding,
- int bufferSize )
- throws IOException
- {
- ByteArrayInputStream in = new ByteArrayInputStream( input );
- copy( in, output, encoding, bufferSize );
- }
-
-
///////////////////////////////////////////////////////////////
// byte[] -> String
@@ -804,7 +472,7 @@
throws IOException
{
StringWriter sw = new StringWriter();
- copy( input, sw, bufferSize );
+ CopyUtils.copy( input, sw, bufferSize );
return sw.toString();
}
@@ -839,42 +507,10 @@
throws IOException
{
StringWriter sw = new StringWriter();
- copy( input, sw, encoding, bufferSize );
+ CopyUtils.copy( input, sw, encoding, bufferSize );
return sw.toString();
}
-
- ///////////////////////////////////////////////////////////////
- // byte[] -> OutputStream
-
- /**
- * Copy bytes from a <code>byte[]</code> to an <code>OutputStream</code>.
- * @param input the byte array to read from
- * @param output the <code>OutputStream</code> to write to
- * @throws IOException In case of an I/O problem
- * @deprecated Replaced by {@link CopyUtils#copy(byte[], OutputStream)}
- */
- public static void copy( byte[] input, OutputStream output )
- throws IOException
- {
- copy( input, output, DEFAULT_BUFFER_SIZE );
- }
-
- /**
- * Copy bytes from a <code>byte[]</code> to an <code>OutputStream</code>.
- * @param input the byte array to read from
- * @param output the <code>OutputStream</code> to write to
- * @param bufferSize Size of internal buffer to use.
- * @throws IOException In case of an I/O problem
- * @deprecated Replaced by {@link CopyUtils#copy(byte[], OutputStream, int)}
- */
- public static void copy( byte[] input,
- OutputStream output,
- int bufferSize )
- throws IOException
- {
- output.write( input );
- }
/**
* Compare the contents of two Streams to determine if they are equal or not.
1.5 +13 -13 jakarta-commons-sandbox/io/src/test/org/apache/commons/io/IOUtilsTestCase.java
Index: IOUtilsTestCase.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/io/src/test/org/apache/commons/io/IOUtilsTestCase.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- IOUtilsTestCase.java 30 Dec 2003 07:00:03 -0000 1.4
+++ IOUtilsTestCase.java 30 Dec 2003 07:06:46 -0000 1.5
@@ -147,7 +147,7 @@
try {
FileOutputStream fout = new FileOutputStream( destination );
try {
- int count = IOUtils.copy( fin, fout );
+ int count = CopyUtils.copy( fin, fout );
assertTrue( "Not all bytes were read", fin.available() == 0 );
assertEquals( "Number of bytes read should equal file size", m_testFile.length(), count );
fout.flush();
@@ -171,7 +171,7 @@
try {
FileWriter fout = new FileWriter( destination );
try {
- IOUtils.copy( fin, fout );
+ CopyUtils.copy( fin, fout );
assertTrue( "Not all bytes were read", fin.available() == 0 );
fout.flush();
@@ -210,10 +210,10 @@
try {
FileOutputStream fout = new FileOutputStream( destination );
try {
- IOUtils.copy( fin, fout );
+ CopyUtils.copy( fin, fout );
//Note: this method *does* flush. It is equivalent to:
// OutputStreamWriter _out = new OutputStreamWriter(fout);
- // IOUtils.copy( fin, _out, 4096 ); // copy( Reader, Writer, int );
+ // CopyUtils.copy( fin, _out, 4096 ); // copy( Reader, Writer, int );
// _out.flush();
// out = fout;
@@ -237,7 +237,7 @@
try {
FileWriter fout = new FileWriter( destination );
try {
- int count = IOUtils.copy( fin, fout );
+ int count = CopyUtils.copy( fin, fout );
assertEquals( "The number of characters returned by copy is wrong", m_testFile.length(), count);
fout.flush();
@@ -282,10 +282,10 @@
FileOutputStream fout = new FileOutputStream( destination );
try {
- IOUtils.copy( str, fout );
+ CopyUtils.copy( str, fout );
//Note: this method *does* flush. It is equivalent to:
// OutputStreamWriter _out = new OutputStreamWriter(fout);
- // IOUtils.copy( str, _out, 4096 ); // copy( Reader, Writer, int );
+ // CopyUtils.copy( str, _out, 4096 ); // copy( Reader, Writer, int );
// _out.flush();
// out = fout;
// note: we don't flush here; this IOUtils method does it for us
@@ -313,7 +313,7 @@
FileWriter fout = new FileWriter( destination );
try {
- IOUtils.copy( str, fout );
+ CopyUtils.copy( str, fout );
fout.flush();
checkFile( destination, m_testFile );
@@ -370,7 +370,7 @@
FileWriter fout = new FileWriter( destination );
try {
- IOUtils.copy( in, fout );
+ CopyUtils.copy( in, fout );
fout.flush();
checkFile( destination, m_testFile );
checkWrite( fout );
@@ -409,7 +409,7 @@
FileOutputStream fout = new FileOutputStream( destination );
try {
- IOUtils.copy( in, fout );
+ CopyUtils.copy( in, fout );
fout.flush();
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org