Hi !
I have some problem with that howework.
I must finish it before tomorrow and I am getting crazy !
I've just created the two files (see the code).
I tried different codes but I still don't get the file in upper case.
Can anyone help me, please !
Thanks in advance

import java.io.*;
/**
 *
 * @author Béatrice
 */
public class ChangeToUpperCaseInputStream extends FilterInputStream {


 //Creates a new instance of ChangeToUpperCaseInputStream
    public ChangeToUpperCaseInputStream(InputStream in){
        super(in);
    }

   /* 1st try
public int read() throws IOException  {
        int result = super.read();
 return (result == -1)? result : Character.toUpperCase((char)result);
    } */

  // 2nd try
    public int read() throws IOException {
        int b = in.read();
        if (b != -1) {
            b= Character.toUpperCase(b);
        }
        return b;
    }

    public int read(byte[] b) throws IOException {
        int len;
        len = in.read(b, 0, b.length);
        if (len != -1) {
            for (int i=0; i<len; i++)
                b[i]= (byte) Character.toUpperCase (b[i]);
        }
        return len;
    }

    public int read(byte[] b, int off, int len) throws IOException {
        len = in.read(b, off, len);
        if (len != -1) {
            for (int i=off; i<(off+len); i++)
                b[i]= (byte) Character.toUpperCase (b[i]);
        }
        return len;
    }
}

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to