import java.io.*;
class ByteArrayTest
{
public static void main(String[] args) throws Exception
{
String tem="abcdefdjfjalfjadlfj";
byte src[]=tem.getBytes();
ByteArrayInputStream input=new ByteArrayInputStream(src);
ByteArrayOutputStream output=new ByteArrayOutputStream();
new ByteArrayTest.transform(input,output);
byte result[]=output.toByteArray();
System.out.println(new String(result));
}
public void transform(InputStream in ,OutputStream out)
{
int c=0;
try
{
while ((c=in.read())!=-1)
{
int e=(int)Character.toUpperCase((char)c);
out.write(e);
}
} catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}
class ByteArrayTest
{
public static void main(String[] args) throws Exception
{
String tem="abcdefdjfjalfjadlfj";
byte src[]=tem.getBytes();
ByteArrayInputStream input=new ByteArrayInputStream(src);
ByteArrayOutputStream output=new ByteArrayOutputStream();
new ByteArrayTest.transform(input,output);
byte result[]=output.toByteArray();
System.out.println(new String(result));
}
public void transform(InputStream in ,OutputStream out)
{
int c=0;
try
{
while ((c=in.read())!=-1)
{
int e=(int)Character.toUpperCase((char)c);
out.write(e);
}
} catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}
==>
new ByteArrayTest().transform(input,output);
语句错了new A()
new ByteArrayTest().transform(input,output);