return IOGroovyMethods.withStream(newObjectInputStream(self, classLoader), closure);
/** * Iterates through the given file object by object. * * @param self a {@code Path} object * @param closure a closure * @throws java.io.IOException if an IOException occurs. * @throws ClassNotFoundException if the class is not found. * @see org.codehaus.groovy.runtime.IOGroovyMethods#eachObject(java.io.ObjectInputStream, groovy.lang.Closure) * @since 2.3.0 */ public static void eachObject(Path self, Closure closure) throws IOException, ClassNotFoundException { IOGroovyMethods.eachObject(newObjectInputStream(self), closure); }
/** * Create a new ObjectInputStream for this file and pass it to the closure. * This method ensures the stream is closed after the closure returns. * * @param path a Path * @param closure a closure * @return the value returned by the closure * @throws java.io.IOException if an IOException occurs. * @see org.codehaus.groovy.runtime.IOGroovyMethods#withStream(java.io.InputStream, groovy.lang.Closure) * @since 2.3.0 */ public static <T> T withObjectInputStream(Path path, @ClosureParams(value = SimpleType.class, options = "java.io.ObjectInputStream") Closure<T> closure) throws IOException { return IOGroovyMethods.withStream(newObjectInputStream(path), closure); }
/** * Create a new ObjectInputStream for this file associated with the given class loader and pass it to the closure. * This method ensures the stream is closed after the closure returns. * * @param self a Path * @param classLoader the class loader to use when loading the class * @param closure a closure * @return the value returned by the closure * @throws java.io.IOException if an IOException occurs. * @see org.codehaus.groovy.runtime.IOGroovyMethods#withStream(java.io.InputStream, groovy.lang.Closure) * @since 2.3.0 */ public static <T> T withObjectInputStream(Path self, ClassLoader classLoader, @ClosureParams(value = SimpleType.class, options = "java.io.ObjectInputStream") Closure<T> closure) throws IOException { return IOGroovyMethods.withStream(newObjectInputStream(self, classLoader), closure); }