All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.frightanic.smn.core.DataLoader Maven / Gradle / Ivy

There is a newer version: 2.0.1
Show newest version
package com.frightanic.smn.core;

import com.frightanic.smn.api.SmnData;
import lombok.SneakyThrows;
import org.apache.commons.io.IOUtils;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;

public class DataLoader {
  private final URL smnDataUrl;

  @SneakyThrows(MalformedURLException.class)
  public DataLoader(String smnDataUrl) {
    this.smnDataUrl = new URL(smnDataUrl);
  }

  public SmnData loadSmnData() throws IOException {
    try (InputStream inputStream = new BufferedInputStream(smnDataUrl.openStream(), 1024)) {
      return new SmnData(IOUtils.toString(inputStream, "UTF-8"));
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy