superclass.constructor.call(this,config),参数问题 [

superclass.constructor.call(this,config),参数问题 [问题点数:20分,结帖人chzhxiang]

  •            
  •            
  •            
  •            
  •            
  •            收藏
  • 回复次数:8
    Sure, here is an example implementation of the ChangeToUpperCaseInputStream and ChangeToUpperCaseOutputStream classes: ```java import java.io.*; public class ChangeToUpperCaseInputStream extends FilterInputStream { public ChangeToUpperCaseInputStream(InputStream in) { super(in); } @Override public int read() throws IOException { int c = super.read(); return (c == -1 ? c : Character.toUpperCase((char) c)); } } public class ChangeToUpperCaseOutputStream extends FilterOutputStream { public ChangeToUpperCaseOutputStream(OutputStream out) { super(out); } @Override public void write(int b) throws IOException { super.write(Character.toUpperCase((char) b)); } } ``` In the above code, the ChangeToUpperCaseInputStream class extends FilterInputStream and overrides the read() method to read the data using the superclass's read() method and convert it to upper case before returning it. Similarly, the ChangeToUpperCaseOutputStream class extends FilterOutputStream and overrides the write() method to convert the data to upper case before calling the superclass's write() method to write it to the output stream. To use these classes in your main program, you can create an instance of ChangeToUpperCaseInputStream or ChangeToUpperCaseOutputStream and pass it to your FileInputStream or FileOutputStream, respectively. Here is an example: ```java import java.io.*; public class MyProgram { public static void main(String[] args) throws IOException { FileInputStream in = new FileInputStream("input.txt"); ChangeToUpperCaseInputStream upperCaseIn = new ChangeToUpperCaseInputStream(in); FileOutputStream out = new FileOutputStream("output.txt"); ChangeToUpperCaseOutputStream upperCaseOut = new ChangeToUpperCaseOutputStream(out); int c; while ((c = upperCaseIn.read()) != -1) { upperCaseOut.write(c); } upperCaseIn.close(); upperCaseOut.close(); } } ``` In the above code, we first create a FileInputStream and wrap it in a ChangeToUpperCaseInputStream. We also create a FileOutputStream and wrap it in a ChangeToUpperCaseOutputStream. We then read data from the input stream using the read() method of the ChangeToUpperCaseInputStream and write data to the output stream using the write() method of the ChangeToUpperCaseOutputStream. Finally, we close both streams to release any resources they are holding.
    评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

    当前余额3.43前往充值 >
    需支付:10.00
    成就一亿技术人!
    领取后你会自动成为博主和红包主的粉丝 规则
    hope_wisdom
    发出的红包
    实付
    使用余额支付
    点击重新获取
    扫码支付
    钱包余额 0

    抵扣说明:

    1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
    2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

    余额充值