Modifier and Type | Field and Description |
---|---|
static int |
BUFFER_SIZE |
Constructor and Description |
---|
URLReader(URL url,
File outfile)
Initialize a new URL Reader.
|
Modifier and Type | Method and Description |
---|---|
Long |
call()
start the URL reader.
|
long |
getBytesRead()
Get the number of bytes downloaded so far.
|
String |
getOutputFile()
Get actual name of the output file.
|
long |
getTotalByte() |
int |
read()
precondition: you need to call
setInput() first. |
long |
readAll()
Read the URL connection and save bytes to output file.
|
void |
setInput()
set this method before
read() |
public URLReader(URL url, File outfile) throws IOException
url
- is the URL to readAll fromoutfile
- is a File output to write output to. If it is a writable directory
then a file is created in that directory with same name as the download resource.IOException
- if URLConnection fails,FileNotFoundException
- if outfile not found or cannot be written topublic long getBytesRead()
public long getTotalByte()
public long readAll() throws IOException
IOException
- when IO error causepublic int read()
setInput()
first. InputStream.read(byte[])
with BUFFER_SIZE
, but add more action is save the result to output stream.null
if cause errorpublic void setInput()
read()
public String getOutputFile()
Copyright © 2017. All rights reserved.