public class DataFile extends DataObject
DataObject.DataObjectTypeclient, dataType, path| Constructor and Description |
|---|
DataFile(HttpClient client,
java.lang.String dataUrl) |
| Modifier and Type | Method and Description |
|---|---|
void |
delete()
Deletes this file.
|
boolean |
exists()
Returns whether the file exists in the Data API
|
byte[] |
getBytes()
Gets the data for this file as as string
|
java.io.File |
getFile()
Gets the data for this file and saves it to a local temporary file
|
java.io.InputStream |
getInputStream()
Gets the data for this file as an InputStream
|
java.lang.String |
getString()
Gets the data for this file as as string using UTF-8 charset
|
java.lang.String |
getString(java.nio.charset.Charset encoding)
Gets the data for this file as as string using a custom charset
|
void |
put(byte[] data)
Upload raw data to this file as binary
|
void |
put(java.io.File file)
Upload new data to this file from an existing file.
|
void |
put(java.io.InputStream is)
Upload raw data to this file as an input stream
|
void |
put(java.lang.String data)
Upload string data to this file as UTF-8 text
|
void |
put(java.lang.String data,
java.nio.charset.Charset charset)
Upload string data to this file as text using a custom Charset
|
getName, getParent, getType, getUrl, isDirectory, isFile, toStringpublic DataFile(HttpClient client, java.lang.String dataUrl)
public boolean exists()
throws APIException
exists in class DataObjectAPIException - if there were any problems communicating with the DataAPIpublic java.io.File getFile()
throws APIException,
java.io.IOException
APIException - if there were any problems communicating with the DataAPIjava.io.IOException - if there were any problems consuming the response contentpublic java.io.InputStream getInputStream()
throws APIException,
java.io.IOException
APIException - if there were any problems communicating with the Algorithmia APIjava.io.IOException - if there were any problems consuming the response contentpublic java.lang.String getString()
throws java.io.IOException
APIException - if there were any problems communicating with the Algorithmia APIjava.io.IOException - if there were any problems consuming the response contentpublic java.lang.String getString(java.nio.charset.Charset encoding)
throws java.io.IOException
encoding - the character encoding of the stringAPIException - if there were any problems communicating with the Algorithmia APIjava.io.IOException - if there were any problems consuming the response contentpublic byte[] getBytes()
throws java.io.IOException
APIException - if there were any problems communicating with the Algorithmia APIjava.io.IOException - if there were any problems consuming the response contentpublic void put(java.lang.String data)
throws APIException
data - the data to uploadAPIException - if there were any problems communicating with the Algorithmia APIpublic void put(java.lang.String data,
java.nio.charset.Charset charset)
throws APIException
data - the data to uploadAPIException - if there were any problems communicating with the Algorithmia APIpublic void put(byte[] data)
throws APIException
data - the data to uploadAPIException - if there were any problems communicating with the Algorithmia APIpublic void put(java.io.InputStream is)
throws APIException
is - the input stream of data to uploadAPIException - if there were any problems communicating with the Algorithmia APIpublic void put(java.io.File file)
throws APIException,
java.io.FileNotFoundException
file - the file to upload data fromAPIException - if there were any problems communicating with the Algorithmia APIjava.io.FileNotFoundException - if the specified file does not existpublic void delete()
throws APIException
APIException - if there were any problems communicating with the Algorithmia API