tags:

views:

527

answers:

5

Actually I try to find a subclass of InputStream which is also Serializable. I think that doesn't exist. Since both Interfaces have many sublclasses it is hard to find one that is a subclass of both.

Until now I haven't found anything to help my search in Eclipse. Anyone ideas?

Edit: I understand now that serializing a Stream isn't really what one should do. But the essence of the Question is: how can I find a common subclass of two Interfaces.

+1  A: 

Serializing an InputStream is not a very viable solution. To illustrate this, imagine if you have an InputStream from a socket and you serialize that. Before you deserialize it, the socket is closed. Now when you actually do deserialize it, the resource has vanished and you have a nasty exception in your hands.

What you should rather do, if you need to serialize a resource, is to serialize the location of it or how to obtain it. In the socket example: host name and port, for files: the file path, etc.

Guðmundur Bjarni
A: 

I am not sure that you can do that in fact (or at least in an easy way...).

Anyway, I like the "Open Implementation" plugin that allows you to right-click on a method of a class or an interface (or the class / interface itself) and ask for all known implementation of this method / interface / class. This plugin may help you (you can now search for all implementation of the InputStream

romaintaz
A: 

http://java.sun.com/j2se/1.5.0/docs/api/java/io/ByteArrayInputStream.html

You could extend it and make it implement Serializable :)

01
+1  A: 

In eclipse the key shortcut Ctrl+T opens the type hierarchy. You can even use this feature on a base class or an interface an you get a list with all implementation/subclasses of this type.

If you do this twice and compare the two results you will find your classes. However in case of e.g. Serializable and Comparable the intersection may become quite huge ...

mkoeller
+1  A: 

Don't be offended, but it sounds to me like you're attempting to solve the wrong problem. What are you really trying to achieve?

JesperE
I was trying to get the content of a file to the server in a 3-tier setting.Nonetheless it was not the first time I tried to figure out a common subclass of 2 Interfaces. Which I still don't know how to do.
boutta