Example usage for java.io UncheckedIOException UncheckedIOException

List of usage examples for java.io UncheckedIOException UncheckedIOException

Introduction

In this page you can find the example usage for java.io UncheckedIOException UncheckedIOException.

Prototype

public UncheckedIOException(IOException cause) 

Source Link

Document

Constructs an instance of this class.

Usage

From source file:objective.taskboard.utils.ZipUtils.java

public static Stream<ZipStreamEntry> stream(File file) {
    try {//w w w .j  a v  a 2 s  .c  o m
        final FileInputStream fileStream = new FileInputStream(file);
        return stream(fileStream).onClose(() -> closeQuietly(fileStream));
    } catch (FileNotFoundException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:org.opendatakit.briefcase.reused.UncheckedFiles.java

public static Path createTempFile(String prefix, String suffix, FileAttribute<?>... attrs) {
    try {//from  w  ww .  j  a v  a 2  s.c om
        return Files.createTempFile(prefix, suffix, attrs);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:org.apache.pulsar.io.file.utils.ZipFiles.java

/**
 * Get a lazily loaded stream of lines from a gzipped file, similar to
 * {@link Files#lines(java.nio.file.Path)}.
 *
 * @param path// w  w  w. ja v a2s.  co m
 *          The path to the zipped file.
 * @return stream with lines.
 */
public static Stream<String> lines(Path path) {
    ZipInputStream zipStream = null;

    try {
        zipStream = new ZipInputStream(Files.newInputStream(path));
    } catch (IOException e) {
        closeSafely(zipStream);
        throw new UncheckedIOException(e);
    }
    // Reader decoder = new InputStreamReader(gzipStream, Charset.defaultCharset());
    BufferedReader reader = new BufferedReader(new InputStreamReader(zipStream));
    return reader.lines().onClose(() -> closeSafely(reader));
}

From source file:se.sawano.java.security.otp.rfc6238.ReferenceDataRepository.java

private static Stream<String> readLines() {
    try {//  w w w .  ja  v  a 2  s. com
        @SuppressWarnings("ConstantConditions")
        final String file = ReferenceDataRepository.class.getClassLoader()
                .getResource("reference-data-rfc6238.txt").getFile();
        final Path p = new File(file).toPath();
        return Files.lines(p);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:com.ftb2om2.util.Zipper.java

public void createOSZ(String mp3Path, String outputPath, List<Difficulty> difficulty) throws IOException {
    FileOutputStream fos = new FileOutputStream(
            outputPath + "\\" + FilenameUtils.getBaseName(mp3Path) + ".osz");
    ZipOutputStream zos = new ZipOutputStream(fos);

    addToZip(mp3Path, "Audio.mp3", zos);

    difficulty.forEach(file -> {//from  w  w  w.  ja  va2s .c o m
        try {
            addToZip(outputPath + "\\" + file.getDifficultyName() + ".osu", file.getDifficultyName() + ".osu",
                    zos);
        } catch (IOException ex) {
            throw new UncheckedIOException(ex);
        }
    });

    zos.close();
    fos.close();
}

From source file:org.bozzo.ipplan.web.json.StreamSerializer.java

@Override
public void serialize(Stream<?> value, JsonGenerator generator, SerializerProvider serializer)
        throws IOException, JsonProcessingException {
    if (value == null) {
        generator.writeNull();/*from  w  w w.  j  av a 2 s  . c om*/
    } else {
        generator.writeStartArray();
        value.forEach(obj -> {
            try {
                generator.writeObject(obj);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        });
        generator.writeEndArray();
    }
}

From source file:edu.umd.umiacs.clip.tools.scor.BM25Scorer.java

public BM25Scorer(IndexReader ir, String field) {
    super(ir, field);
    k1 = 1.2f;/*from ww  w .  j av a2 s .  c  om*/
    b = 0.75f;
    try {
        avgdl = ir.getSumTotalTermFreq(field) / (float) ir.numDocs();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    cache = new float[(int) (avgdl * 10)];
    for (int i = 0; i < cache.length; i++) {
        cache[i] = k1 * (1 - b + b * (i / avgdl));
    }
}

From source file:org.apache.pulsar.io.file.utils.GZipFiles.java

/**
 * Get a lazily loaded stream of lines from a gzipped file, similar to
 * {@link Files#lines(java.nio.file.Path)}.
 *
 * @param path/*  w w  w.j  a  va2 s.c  o  m*/
 *          The path to the gzipped file.
 * @return stream with lines.
 */
public static Stream<String> lines(Path path) {
    GZIPInputStream gzipStream = null;

    try {
        gzipStream = new GZIPInputStream(Files.newInputStream(path));
    } catch (IOException e) {
        closeSafely(gzipStream);
        throw new UncheckedIOException(e);
    }

    BufferedReader reader = new BufferedReader(new InputStreamReader(gzipStream));
    return reader.lines().onClose(() -> closeSafely(reader));
}

From source file:net.morimekta.idltool.IdlUtils.java

public static String versionString() {
    Properties properties = new Properties();
    try (InputStream in = IdlUtils.class.getResourceAsStream("/build.properties")) {
        properties.load(in);//from   w  w w .  java  2 s.  c  o  m
        return "v" + properties.getProperty("build.version");
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:fr.javatic.mongo.jacksonCodec.JacksonCodec.java

@Override
public T decode(BsonReader reader, DecoderContext decoderContext) {
    try {//  w w  w .  ja v  a 2  s. c om
        RawBsonDocument document = rawBsonDocumentCodec.decode(reader, decoderContext);
        return bsonObjectMapper.readValue(document.getByteBuffer().array(), type);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}