Package com.google.common.io

Examples of com.google.common.io.Closer.register()


        File output = getOutputFile();
        CompressionMode comp = CompressionMode.autodetect(output);
        logger.info("writing model to {}", output);
        Closer closer = Closer.create();
        try {
            OutputStream stream = closer.register(new FileOutputStream(output));
            stream = closer.register(comp.wrapOutput(stream));
            engine.write(stream);
        } catch (Throwable th) {
            throw closer.rethrow(th);
        } finally {
View Full Code Here


        CompressionMode comp = CompressionMode.autodetect(output);
        logger.info("writing model to {}", output);
        Closer closer = Closer.create();
        try {
            OutputStream stream = closer.register(new FileOutputStream(output));
            stream = closer.register(comp.wrapOutput(stream));
            engine.write(stream);
        } catch (Throwable th) {
            throw closer.rethrow(th);
        } finally {
            closer.close();
View Full Code Here

            flags.add(BinaryFormatFlag.TIMESTAMPS);
        }
        logger.info("packing to {} with flags {}", getOutputFile(), flags);
        Closer closer = Closer.create();
        try {
            BinaryRatingPacker packer = closer.register(BinaryRatingPacker.open(getOutputFile(), flags));
            Cursor<Rating> ratings = closer.register(dao.streamEvents(Rating.class));
            packer.writeRatings(ratings);
            logger.info("packed {} ratings", packer.getRatingCount());
        } catch (Throwable th) {
            throw closer.rethrow(th);
View Full Code Here

        }
        logger.info("packing to {} with flags {}", getOutputFile(), flags);
        Closer closer = Closer.create();
        try {
            BinaryRatingPacker packer = closer.register(BinaryRatingPacker.open(getOutputFile(), flags));
            Cursor<Rating> ratings = closer.register(dao.streamEvents(Rating.class));
            packer.writeRatings(ratings);
            logger.info("packed {} ratings", packer.getRatingCount());
        } catch (Throwable th) {
            throw closer.rethrow(th);
        } finally {
View Full Code Here

            }

            Closer closer = Closer.create();
            try {
                try {
                    BinaryRatingPacker packer = closer.register(BinaryRatingPacker.open(file, flags));
                    Cursor<Rating> ratings = closer.register(dao.streamEvents(Rating.class, order));
                    packer.writeRatings(ratings);
                } catch (Throwable th) {
                    throw closer.rethrow(th);
                } finally {
View Full Code Here

            Closer closer = Closer.create();
            try {
                try {
                    BinaryRatingPacker packer = closer.register(BinaryRatingPacker.open(file, flags));
                    Cursor<Rating> ratings = closer.register(dao.streamEvents(Rating.class, order));
                    packer.writeRatings(ratings);
                } catch (Throwable th) {
                    throw closer.rethrow(th);
                } finally {
                    closer.close();
View Full Code Here

     */
    public static LongList readIdList(File file) throws IOException {
        LongList items = new LongArrayList();
        Closer closer = Closer.create();
        try {
            FileReader fread = closer.register(new FileReader(file));
            BufferedReader buf = closer.register(new BufferedReader(fread));
            String line;
            int lno = 0;
            while ((line = buf.readLine()) != null) {
                lno += 1;
View Full Code Here

    public static LongList readIdList(File file) throws IOException {
        LongList items = new LongArrayList();
        Closer closer = Closer.create();
        try {
            FileReader fread = closer.register(new FileReader(file));
            BufferedReader buf = closer.register(new BufferedReader(fread));
            String line;
            int lno = 0;
            while ((line = buf.readLine()) != null) {
                lno += 1;
                if (line.trim().isEmpty()) {
View Full Code Here

            Enumeration<URL> urls = loader.getResources("META-INF/classes.lst");
            while (urls.hasMoreElements()) {
                URL url = urls.nextElement();
                Closer closer = Closer.create();
                try {
                    InputStream stream = closer.register(url.openStream());
                    Reader rdr = closer.register(new InputStreamReader(stream, "UTF-8"));
                    BufferedReader buf = closer.register(new BufferedReader(rdr));
                    String line = buf.readLine();
                    while (line != null) {
                        int idx = line.lastIndexOf('.');
View Full Code Here

            while (urls.hasMoreElements()) {
                URL url = urls.nextElement();
                Closer closer = Closer.create();
                try {
                    InputStream stream = closer.register(url.openStream());
                    Reader rdr = closer.register(new InputStreamReader(stream, "UTF-8"));
                    BufferedReader buf = closer.register(new BufferedReader(rdr));
                    String line = buf.readLine();
                    while (line != null) {
                        int idx = line.lastIndexOf('.');
                        if (idx >= 0) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.