Question: I have simple google maps div element. When user clicks `Submit` button expensive calculations gets trigged on backend therefore I want fade the whole google map in order to prevent user from navigating over and illustrate that job is in progress.

Simplified example: <http://jsfiddle.net/8jhsxbpo/4/>

```
  <div id="map_canvas" ></div>
  <button ng-click="getPlace()" type="button">Submit</button>

```

Note: Submit is not blocking the rest of the page. Doing it using angular `$http` service. 

```
$scope.getPlace = function(term, locale) {
    return $http.get('http://localhost:8080/search', {
        params: {
            term: term,
            locale: locale
        }
    }).then(function(response){
        renderMap(response);
    });
};

```

My project is written on Bootstrap 3 + Angular Js. 

Question: How do I fade or disable element and display loading icon while job is in progress?

Answer: 
`ObjectInputStream`, internally uses a `BlockDataInputStream` perform its read operations. This reads a block of data and not just a byte as we expect, when you call a `read`. It reads a byte only if it falls as a "block"

The output is not what I was expecting either.
But, if you look at the code of `ObjectInputStream.read()`, it makes sense.

So, in your case it makes sense to use only `readObject` to restore your objects' state.

Heres your code again...

```
class SimpleJava {

    public static void open(InputStream input, OutputStream output) throws IOException {

        try {
            ObjectInputStream ois = new ObjectInputStream(input);
            System.out.println(ois.available());// 0
            System.out.println(ois.available() + " " + ois.read() + " " + ois.read());// 0 -1 -1
            // Reads the object even if the available returned 0 
            // and ois.read() returned -1
            System.out.println("object:" + ois.readObject());// object:abcd
        }
        catch (Exception ioe) {
            ioe.printStackTrace();
        }
    }

    static void open(Path path) throws IOException {

        if (path != null) {
            ByteArrayInputStream in = null;
            if (Files.exists(path)) {
                byte[] data = Files.readAllBytes(path);
                in = new ByteArrayInputStream(data);
            }
            OutputStream out = Files.newOutputStream(path);
            open(in, out);
        }
    }

    public static void main(String[] args) throws Exception {

        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(new File("/home/pradhan/temp.object")));
        oos.writeObject("abcd");//writes a string object for us to read later
        oos.close();
        //
        open(FileSystems.getDefault().getPath("/home/user/temp.object"));
    }
}

```

Heres the output...

```
0
0 -1 -1
object:abcd

```
The problem was that I was reading the `ObjectInputStream` the wrong way. It was like:

```
read.readExternal(ois);

```

but the correct way is:

```
read = (Product)ois.readObject();

```

And beacause of the Exceptions I was getting for doing so, I thought that the problem was with the construction of `ObjectInputStream` when using `ByteArrayInputStream`.
What a big mistake! :D

Thanks to everybody that tried to help.