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 class
URLInputSource.Builder
Builder class for an URLInputSource.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static URLInputSource.Builder
builder(String url)
void
cleanup()
protected HttpURLConnection
createConnection(String urlString)
void
fetchFile()
Fetches the file from a remote source.String
getLocalFilename()
void
saveToFile(String filepath)
Fetches the file from the URL and saves it to the specified filepath.LocalInputSource
toLocalInputSource()
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 IOException
Fetches 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()
-
getLocalFilename
public String getLocalFilename()
-
-