Class BufferedInputStream causes that debugger cannot suspend in any breakpoint?

53 Views Asked by At

This is the function causing the problem: the program won't be suspended in any breakpoint, therefore, I am not clear of the detail in this function.

public static short[] readHgtFile2short(File file) throws IOException {

        BufferedInputStream fis = new BufferedInputStream(new FileInputStream(file));

        byte[] bytes = new byte[1024];

        byte[] bytes_all = new byte[SAMPLES*SAMPLES*2];

        int length = 0;
        int i = 0;

        while ((length = fis.read(bytes)) != -1) {
            for(int j = 0; j< length;j++)
                bytes_all[i+j] = bytes[j];
            i+=length;
        }

        fis.close();


        short[] st = new short[SAMPLES*SAMPLES];
        for(int k = 0;k<SAMPLES*SAMPLES;k++){
            byte[] t = new byte[2];
            t[0] = bytes_all[2*k];
            t[0] = bytes_all[2*k+1];

            st[k] = bytes2Short(t);
        }
       
        return st;
    }

I tried to resolve this problem by delete some codes. I find that if the first line of codes "BufferedInputStream fis = new BufferedInputStream(new FileInputStream(file));" is reserved, the problem was still stuck, unless I just reserve the last two lines.

public static short[] readHgtFile2short(File file) throws IOException {

        Short[] st = new Short[SAMPLES*SAMPLES];
        return st;
    }

I think the problem is caused by BufferedInputStream, but I cannot find similiar questions in stackoverflow and other websites.

0

There are 0 best solutions below