import java.io.OutputStream; import java.io.FileOutputStream; public class InstOfTest { public static void main (String[] args) { try { FileOutputStream f = new FileOutputStream("/tmp/foo"); if (f instanceof OutputStream) { System.out.println("The f object is an OutputStream"); } } catch (Exception e){ e.printStackTrace(); } } } |
program-id. InstOfTest. configuration section. repository. class OutputStream as "java.io.OutputStream" class FileOutputStream as "java.io.FileOutputStream" class JClass as "java.lang.Class" class JSystem as "java.lang.System" . working-storage section. 77 f object reference FileOutputStream. procedure division. main. try set f to FileOutputStream:>new("/tmp/foo") if JClass:>forName("java.io.OutputStream") :>isAssignableFrom (f:>getClass()) JSystem:>out:>println ("The f object is an OutputStream") end-if catch exception exception-object:>printStackTrace() end-try. goback. |