public class FSPutil extends Object
There are some higher level function for working with FSP.
Constructor and Description |
---|
FSPutil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
canUpload(FSPsession session,
String filename)
Checks if user have enough rights to upload given file.
|
static void |
download(FSPsession session,
String filename,
OutputStream os,
long start_from,
long byteswanted)
Downloads a file from FSP server.
|
static String[] |
list(FSPsession session,
String directory)
get a filename directory list from server.
|
static FSPstat |
stat(FSPsession session,
String path)
Gets information about file or directory.
|
static FSPstat[] |
statlist(FSPsession session,
String directory)
get a FSPstat directory list from server.
|
static boolean |
statSupported(FSPsession session)
Check if FSP server supports CC_STAT command.
|
static byte[] |
stringToASCIIZ(String filename)
Converts String to ASCIIZ byte array.
|
static void |
upload(FSPsession session,
String filename,
InputStream is,
long timestamp)
Uploads file to FSP server
|
static FSPversion |
version(FSPsession session)
Sends CC_VERSION command to server and parses reply.
|
public static void download(FSPsession session, String filename, OutputStream os, long start_from, long byteswanted) throws IOException
This procedure download a file from FSP server, file is written to OutputStream. OutputStream is not closed at end of transfer.
session
- active FSP sessionfilename
- filename on FSP serveros
- write file to this streamstart_from
- offset where to start downloadbyteswanted
- how many bytes to download, < 0 for allIOException
- if i/o or net error ocured during file transferpublic static void upload(FSPsession session, String filename, InputStream is, long timestamp) throws IOException
session
- opened FSPsession to target serverfilename
- filename on remote serveris
- InputStream to be sent to server. Stream is not closed at
end of operationtimestamp
- timestamp for uploaded file, 0 if not used. Timestamp
in in standard Java format (milliseconds)IOException
- if i/o or net error ocured during file transferpublic static FSPstat stat(FSPsession session, String path) throws IOException
This function requests information about specific path from FSP server. Server must support CC_STAT command, which is supported from FSP 2.8.1 Beta 11.
session
- FSPsessionpath
- path for getting informationIOException
- if server is not responding or do not supports
CC_STAT commandFSPstat
,
statSupported(FSPsession)
public static boolean statSupported(FSPsession session) throws IOException
This function is also suitable for detecting if FSP server is still alive. If you dont get IOException during function call then you are still connected to FSP server.
session
- FSPsessionIOException
- if server can not be contactedpublic static byte[] stringToASCIIZ(String filename)
filename
- string to be convertedpublic static String[] list(FSPsession session, String directory) throws IOException
session
- live FSPsessiondirectory
- directory to be listedIOException
- if network failure ocurspublic static FSPstat[] statlist(FSPsession session, String directory) throws IOException
session
- live FSPsessiondirectory
- directory to be listedIOException
- if network error ocursFSPstat
public static FSPversion version(FSPsession session) throws IOException
statSupported
function instead.session
- live FSPsessionIOException
- if there is problem with server communicationstatSupported(FSPsession)
public static boolean canUpload(FSPsession session, String filename) throws IOException
session
- opened FSPsessionfilename
- file to be uploadedIOException
- if there is server communication problemCopyright © 2020 FSP Project. All rights reserved.