Package com.mindee.input
Class URLInputSource
- java.lang.Object
-
- com.mindee.input.URLInputSource
-
public class URLInputSource extends Object
Input source wrapper to load remote files locally.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classURLInputSource.BuilderBuilder class for an URLInputSource.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static URLInputSource.Builderbuilder(String url)voidcleanup()protected HttpURLConnectioncreateConnection(String urlString)voidfetchFile()Fetches the file from a remote source.StringgetLocalFilename()StringgetUrl()voidsaveToFile(String filepath)Fetches the file from the URL and saves it to the specified filepath.LocalInputSourcetoLocalInputSource()Create a LocalInputSource instance from this object.
-
-
-
Method Detail
-
builder
public static URLInputSource.Builder builder(String url)
- Parameters:
url- URL to fetch the file from.- Returns:
- An instance of
URLInputSource.
-
fetchFile
public void fetchFile() throws IOExceptionFetches the file from a remote source.- Throws:
IOException- Throws if the file can't be fetched.
-
createConnection
protected HttpURLConnection createConnection(String urlString) throws IOException
- Throws:
IOException
-
toLocalInputSource
public LocalInputSource toLocalInputSource() throws IOException
Create a LocalInputSource instance from this object.- Returns:
- An instance of a
LocalInputSource. - Throws:
IOException- Throws if the file can't be accessed.
-
saveToFile
public void saveToFile(String filepath) throws IOException
Fetches the file from the URL and saves it to the specified filepath.- Parameters:
filepath- The local path where the file should be saved.- Throws:
IOException- If there's an error fetching or saving the file.
-
cleanup
public void cleanup()
-
getUrl
public String getUrl()
-
getLocalFilename
public String getLocalFilename()
-
-