1 32 package net.sf.retrotranslator.runtime.java.io; 33 34 import java.io.*; 35 import java.nio.channels.Channel ; 36 37 40 public class _Closeable { 41 42 public static boolean executeInstanceOfInstruction(Object object) { 43 return object instanceof InputStream || 44 object instanceof OutputStream || 45 object instanceof Reader || 46 object instanceof Writer || 47 object instanceof RandomAccessFile || 48 object instanceof Channel || 49 object instanceof Closeable_; 50 } 51 52 public static Object executeCheckCastInstruction(Object object) { 53 if (object instanceof InputStream) { 54 return (InputStream) object; 55 } 56 if (object instanceof OutputStream) { 57 return (OutputStream) object; 58 } 59 if (object instanceof Reader) { 60 return (Reader) object; 61 } 62 if (object instanceof Writer) { 63 return (Writer) object; 64 } 65 if (object instanceof RandomAccessFile) { 66 return (RandomAccessFile) object; 67 } 68 if (object instanceof Channel ) { 69 return (Channel ) object; 70 } 71 return (Closeable_) object; 72 } 73 74 public static void close(Object object) throws IOException { 75 if (object instanceof InputStream) { 76 ((InputStream) object).close(); 77 } else if (object instanceof OutputStream) { 78 ((OutputStream) object).close(); 79 } else if (object instanceof Reader) { 80 ((Reader) object).close(); 81 } else if (object instanceof Writer) { 82 ((Writer) object).close(); 83 } else if (object instanceof RandomAccessFile) { 84 ((RandomAccessFile) object).close(); 85 } else if (object instanceof Channel ) { 86 ((Channel ) object).close(); 87 } else { 88 ((Closeable_) object).close(); 89 } 90 } 91 92 } 93 | Popular Tags |