Package com.zebra.sdk.device
Interface FileUtil
- All Known Subinterfaces:
ZebraPrinter,ZebraPrinterLinkOs
- All Known Implementing Classes:
Profile
public interface FileUtil
This is an utility class for performing file operations on a device.
package test.zebra.sdk.device.examples;
import com.zebra.sdk.comm.Connection;
import com.zebra.sdk.comm.ConnectionException;
import com.zebra.sdk.comm.TcpConnection;
import com.zebra.sdk.device.ZebraIllegalArgumentException;
import com.zebra.sdk.printer.ZebraPrinter;
import com.zebra.sdk.printer.ZebraPrinterFactory;
import com.zebra.sdk.printer.ZebraPrinterLanguageUnknownException;
public class FileUtilExample {
public static void main(String[] args) throws Exception {
Connection connection = new TcpConnection("192.168.1.100", TcpConnection.DEFAULT_ZPL_TCP_PORT);
try {
connection.open();
ZebraPrinter printer = ZebraPrinterFactory.getInstance(connection);
printer.sendFileContents("/sdcard/documents/labels/sample.lbl");
String[] fileNames = printer.retrieveFileNames();
for (String filename : fileNames) {
System.out.println(filename);
}
} catch (ConnectionException e) {
e.printStackTrace();
} catch (ZebraPrinterLanguageUnknownException e) {
e.printStackTrace();
} catch (ZebraIllegalArgumentException e) {
e.printStackTrace();
} finally {
connection.close();
}
}
}
-
Method Summary
Modifier and TypeMethodDescriptionString[]Retrieves the names of the files which are stored on the device.String[]retrieveFileNames(String[] extensions) Retrieves the names of the files which are stored on the device.Retrieves the properties of the objects which are stored on the device.voidsendFileContents(String filePath) Sends the contents of a file to the device.voidsendFileContents(String filePath, ProgressMonitor handler) Sends the contents of a file to the device.
-
Method Details
-
sendFileContents
Sends the contents of a file to the device.- Parameters:
filePath- the full file path (e.g. "C:\\Users\\%USERNAME%\\Documents\\sample.lbl").- Throws:
ConnectionException- if there is an issue communicating with the device (e.g. the connection is not open).
-
sendFileContents
Sends the contents of a file to the device.- Parameters:
filePath- the full file path (e.g. "C:\\Users\\%USERNAME%\\Documents\\sample.lbl").handler- callback to update on progress- Throws:
ConnectionException- if there is an issue communicating with the device (e.g. the connection is not open).
-
retrieveFileNames
Retrieves the names of the files which are stored on the device.- Returns:
- list of file names.
- Throws:
ConnectionException- if there is an error connecting to the device.ZebraIllegalArgumentException- if there is an error parsing the directory data returned by the device.
-
retrieveFileNames
String[] retrieveFileNames(String[] extensions) throws ConnectionException, ZebraIllegalArgumentException Retrieves the names of the files which are stored on the device. This method only returns files which have one of the extensions inextensions.- Parameters:
extensions- the extensions to filter on.- Returns:
- list of file names.
- Throws:
ConnectionException- if there is an error connecting to the device.ZebraIllegalArgumentException- if there is an error parsing the directory data returned by the device.
-
retrieveObjectsProperties
List<PrinterObjectProperties> retrieveObjectsProperties() throws ConnectionException, ZebraIllegalArgumentExceptionRetrieves the properties of the objects which are stored on the device.- Returns:
- the list of objects with their properties.
- Throws:
ConnectionException- if there is an error connecting to the device.ZebraIllegalArgumentException- if there is an error parsing the directory data returned by the device.
-