public class Resource extends Object
Constructor and Description |
---|
Resource() |
Modifier and Type | Method and Description |
---|---|
static void |
copy(Connection connection,
String inPath,
File outFile)
Copies a file from a URI path to an opened local file.
|
static void |
copy(Connection connection,
String inPath,
String outPath)
Copy a file using an opened connection to a remote host.
|
static void |
copy(InputStream inStream,
OutputStream outStream)
Copy one stream to another.
|
static void |
copy(String inPath,
File outFile)
Copies a file from a URI path to an opened local file.
|
static void |
copy(String inPath,
String outPath,
boolean withCipher,
String keyFile)
Copy a file from one location to another.
|
static void |
createPath(Connection connection,
String outPath)
Safely create path
|
static void |
createPath(File path)
Safely create path
|
static boolean |
fromFTP(SimpleFTP ftp,
String inPath,
OutputStream out)
Copy a file from a remote host using the FTP protocol and write to a local file.
|
static boolean |
fromFTP(SimpleFTP ftp,
String inPath,
String outPath)
Copy a file from a remote host using the FTP protocol and write to a local file.
|
static boolean |
fromFTP(String inPath,
OutputStream outStream)
Open a file referenced by a URI with FTP protocol and write to an opened output stream.
|
static boolean |
fromFTP(String inPath,
String outPath)
Open a file referenced by a URI with FTP protocol and write to local file.
|
static boolean |
fromSCP(Scp scp,
String inPath,
String outPath)
Copy a file from a remote host using the SSH protocol and write to a local file.
|
static boolean |
fromSCP(String inPath,
String outPath,
boolean withCipher,
String keyFile)
Copy a file from a remote host using the SSH protocol and write to a local file.
|
static String |
getHost(String path)
Returns the host information portion of a URI.
|
static InputStream |
getHTTPSStream(String url,
String cookies)
Create an input stream to a file given a URI with the HTTP protocol.
|
static InputStream |
getHTTPStream(String url,
String cookies)
Create an input stream to a file given a URI with the HTTP protocol.
|
static InputStream |
getInputStream(String path)
Create an input stream to a file given a URI path.
|
static String |
getLocation(String path)
Returns the location portion of a URI.
|
static OutputStream |
getOutputStream(String path)
Create an output stream to a file given a URI path.
|
static String |
getPath(String path)
Returns the path information portion of a URI.
|
static String |
getProtocol(String path)
Returns the protocol portion of a URI.
|
static InputStream |
getURLStream(String url,
String cookies)
Create an input stream to a file given a URI path.
|
static String |
getUserInfo(String path)
Returns the user information portion of a URI.
|
static boolean |
isFile(String path)
Determines if the protocol is "file".
|
static boolean |
isFTP(String path)
Determines if the protocol is "ftp".
|
static boolean |
isHTTP(String path)
Determines if the protocol is "http".
|
static boolean |
isHTTPS(String path)
Determines if the protocol is "https".
|
static boolean |
isSCP(String path)
Determines if the protocol is "scp".
|
static void |
main(String[] args)
Command-line interface.
|
static void |
pull(Connection connection,
String inPath,
String outPath)
Copies a file from a known remote URI path to a local file.
|
static void |
push(Connection connection,
String inPath,
String outPath)
Copies a file to a known remote URI path from a local file.
|
static void |
remove(Connection connection,
String remotePath)
Removes a file from a URI path .
|
static void |
removeFTP(SimpleFTP ftp,
String remotePath)
Remove a file referenced by a URI with FTP protocol.
|
static void |
removeFTP(String remotePath)
Remove a file referenced by a URI with FTP protocol.
|
static boolean |
removeSCP(Scp scp,
String remotePath)
Remove a file from a remote host using the SSH protocol.
|
static boolean |
toFTP(SimpleFTP ftp,
String inPath,
String outPath)
Copy a file from a local location to a remote host using the FTP protocol.
|
static boolean |
toFTP(String inPath,
String outPath)
Copy a file from a local location to a remote host using the FTP protocol.
|
static boolean |
toSCP(Scp scp,
String inPath,
String outPath)
Copy a file from a local location to a remote host using the SSH protocol.
|
static boolean |
toSCP(String inPath,
String outPath,
boolean withCipher,
String keyFile)
Copy a file from a local location to a remote host using the SSH protocol.
|
static void |
trustAllCerts()
Configure HttpsURLConnection to trust all certs.
|
public static void main(String[] args)
args
- command-line arguments.public static void trustAllCerts() throws Exception
Exception
public static InputStream getInputStream(String path) throws IOException
path
- the URI to the file.InputStream
to the file.IOException
- if unable to create a stream.public static OutputStream getOutputStream(String path) throws IOException
path
- the URI to the file.OutputStream
to the file.IOException
- if unable to create a stream.public static String getProtocol(String path)
path
- The URI to parse.public static String getLocation(String path)
path
- The URI to parse.public static String getUserInfo(String path)
path
- The URI to parse.public static String getHost(String path)
path
- The URI to parse.public static String getPath(String path)
path
- The URI to parse.public static boolean isFTP(String path)
path
- The URI to parse.public static boolean isSCP(String path)
path
- the URI to parse.public static boolean isFile(String path)
path
- the URI to parse.public static boolean isHTTP(String path)
path
- the URI to parse.public static boolean isHTTPS(String path)
path
- the URI to parse.public static void remove(Connection connection, String remotePath) throws IOException, com.jcraft.jsch.JSchException
connection
- an established connection to a remote host.remotePath
- the URI of the file to remove.IOException
- if any error occurs.com.jcraft.jsch.JSchException
public static void copy(String inPath, String outPath, boolean withCipher, String keyFile) throws com.jcraft.jsch.JSchException, Exception
inPath
- the URI of the file to copy.outPath
- the URI of the destination of the copy.withCipher
- whether to encrypt the data transfer. True will encrypt.keyfile
- the name of the file contain the SSH key. Used only with the scp protocolcom.jcraft.jsch.JSchException
- if an error occurs making an SSH connectionException
- if any other error occurs.public static void copy(Connection connection, String inPath, String outPath) throws IOException, com.jcraft.jsch.JSchException
connection
- an open connection to a remote host.inPath
- the URI of the file to copy.outPath
- the URI of the destination of the copy.IOException
- if an error occurscom.jcraft.jsch.JSchException
- scp errorpublic static void copy(String inPath, File outFile) throws IOException
inPath
- the URI of the file to copy.outFile
- the opened destination file.IOException
- if any error occurs.public static void copy(Connection connection, String inPath, File outFile) throws IOException
connection
- an established connection to a remote host.inPath
- the URI of the file to copy.outFile
- the opened destination file.IOException
- if any error occurs.public static void pull(Connection connection, String inPath, String outPath) throws IOException, Exception
connection
- an established connection to a remote host.inPath
- the URI of the file to copy.outPath
- the local path for the destination of the copy.IOException
- if any error occurs.Exception
public static void createPath(Connection connection, String outPath) throws IOException, Exception
connection
- an established connection to a remote host.pathname
- the path to createException
IOException
public static void createPath(File path) throws Exception
pathname
- the path to createException
public static void push(Connection connection, String inPath, String outPath) throws IOException, com.jcraft.jsch.JSchException
connection
- an established connection to a remote host.inPath
- the local path of the file to copy.outPath
- the URI of the destination of the copy.IOException
- if any error occurs.com.jcraft.jsch.JSchException
public static void copy(InputStream inStream, OutputStream outStream) throws IOException
inStream
- an opened InputStream
for the source of the copy.outStream
- an opened (@link OutputStream} for the destination of the copy.IOException
- if any errors occur.public static InputStream getURLStream(String url, String cookies) throws IOException
inPath
- the URI of the remote file to copy.cookies
- cookies associated with the connection.InputStream
to the file.IOException
- if any error occurs.public static InputStream getHTTPStream(String url, String cookies) throws IOException
inPath
- the URI of the remote file to copy.cookies
- cookies associated with the connection.InputStream
to the file.IOException
- if any error occurs.public static InputStream getHTTPSStream(String url, String cookies) throws IOException
inPath
- the URI of the remote file to copy.cookies
- cookies associated with the connection.InputStream
to the file.IOException
- if any error occurs.public static void removeFTP(String remotePath) throws IOException
remotePath
- the URI of the file to remove.IOException
- if any error occurs.public static void removeFTP(SimpleFTP ftp, String remotePath) throws IOException
ftp
- the open FTP connection to a remote host.remotePath
- the URI of the file to remove.IOException
- if any error occurs.public static boolean fromFTP(String inPath, String outPath) throws IOException
inPath
- the URI of the file to copy.outPath
- the path for the destination of the copy.IOException
- if any error occurs.public static boolean fromFTP(String inPath, OutputStream outStream) throws IOException
inPath
- the URI of the remote file to copy.outStream
- the opened OutputStream
for the destination of the copy.IOException
- if any error occurs.public static boolean fromFTP(SimpleFTP ftp, String inPath, String outPath) throws IOException
ftp
- the open FTP connection to a remote host.inPath
- the URI of the remote file to copy.outPath
- the path for the destination of the copy.IOException
- if any error occurs.public static boolean fromFTP(SimpleFTP ftp, String inPath, OutputStream out)
ftp
- the open FTP connection to a remote host.inPath
- the URI of the remote file to copy.out
- the opened OutputStream
for the destination of the copy.IOException
- if any error occurs.public static boolean toFTP(String inPath, String outPath) throws IOException
inPath
- the URI of the file to copy.outPath
- the path for the destination of the copy.IOException
- if any error occurs.public static boolean toFTP(SimpleFTP ftp, String inPath, String outPath) throws IOException
ftp
- an established connection to a remote host.inPath
- the URI of the file to copy.outPath
- the path for the destination of the copy.IOException
- if any error occurs.public static boolean removeSCP(Scp scp, String remotePath) throws IOException, com.jcraft.jsch.JSchException
scp
- the open SCP connection to a remote host.remotePath
- the URI of the remote file to remove.IOException
- if any error occurs.com.jcraft.jsch.JSchException
public static boolean fromSCP(String inPath, String outPath, boolean withCipher, String keyFile) throws com.jcraft.jsch.JSchException, Exception
inPath
- the URI of the remote file to copy.outStream
- the opened OutputStream
for the destination of the copy.withCipher
- whether to encrypt the data transfer. True will encrypt.keyfile
- the name of the file contain the SSH key. Used only with the scp protocolIOException
- if any error occurs.com.jcraft.jsch.JSchException
Exception
public static boolean fromSCP(Scp scp, String inPath, String outPath) throws IOException
scp
- the open SCP connection to a remote host.inPath
- the URI of the remote file to copy.outStream
- the opened OutputStream
for the destination of the copy.IOException
- if any error occurs.public static boolean toSCP(String inPath, String outPath, boolean withCipher, String keyFile) throws com.jcraft.jsch.JSchException, Exception
inPath
- the URI of the file to copy.outPath
- the path for the destination of the copy.withCipher
- whether to encrypt the data transfer. True will encrypt.keyfile
- the name of the file contain the SSH key. Used only with the scp protocolIOException
- if any error occurs.com.jcraft.jsch.JSchException
Exception
public static boolean toSCP(Scp scp, String inPath, String outPath) throws IOException, com.jcraft.jsch.JSchException
scp
- an established connection to a remote host.inPath
- the URI of the file to copy.outPath
- the path for the destination of the copy.IOException
- if any error occurs.com.jcraft.jsch.JSchException
Copyright © 2014-2016 Regents University of California. All Rights Reserved.