List of usage examples for org.apache.commons.net.tftp TFTPClient setDefaultTimeout
public void setDefaultTimeout(int timeout)
From source file:com.app.safari.tftp.java
public final static void main(String[] args) { boolean receiveFile = true, closed; int transferMode = TFTP.BINARY_MODE, argc; String arg, hostname, localFilename, remoteFilename; TFTPClient tftp; // Parse options for (argc = 0; argc < args.length; argc++) { arg = args[argc];/*w w w .j a v a 2 s .co m*/ if (arg.startsWith("-")) { if (arg.equals("-r")) receiveFile = true; else if (arg.equals("-s")) receiveFile = false; else if (arg.equals("-a")) transferMode = TFTP.ASCII_MODE; else if (arg.equals("-b")) transferMode = TFTP.BINARY_MODE; else { System.err.println("Error: unrecognized option."); System.err.print(USAGE); System.exit(1); } } else break; } // Make sure there are enough arguments if (args.length - argc != 3) { System.err.println("Error: invalid number of arguments."); System.err.print(USAGE); System.exit(1); } // Get host and file arguments hostname = args[argc]; localFilename = args[argc + 1]; remoteFilename = args[argc + 2]; // Create our TFTP instance to handle the file transfer. tftp = new TFTPClient(); // We want to timeout if a response takes longer than 60 seconds tftp.setDefaultTimeout(60000); // Open local socket try { tftp.open(); } catch (SocketException e) { System.err.println("Error: could not open local UDP socket."); System.err.println(e.getMessage()); System.exit(1); } // We haven't closed the local file yet. closed = false; // If we're receiving a file, receive, otherwise send. if (receiveFile) { FileOutputStream output = null; File file; file = new File(localFilename); // If file exists, don't overwrite it. if (file.exists()) { System.err.println("Error: " + localFilename + " already exists."); System.exit(1); } // Try to open local file for writing try { output = new FileOutputStream(file); } catch (IOException e) { tftp.close(); System.err.println("Error: could not open local file for writing."); System.err.println(e.getMessage()); System.exit(1); } // Try to receive remote file via TFTP try { tftp.receiveFile(remoteFilename, transferMode, output, hostname); } catch (UnknownHostException e) { System.err.println("Error: could not resolve hostname."); System.err.println(e.getMessage()); System.exit(1); } catch (IOException e) { System.err.println("Error: I/O exception occurred while receiving file."); System.err.println(e.getMessage()); System.exit(1); } finally { // Close local socket and output file tftp.close(); try { output.close(); closed = true; } catch (IOException e) { closed = false; System.err.println("Error: error closing file."); System.err.println(e.getMessage()); } } if (!closed) System.exit(1); } else { // We're sending a file FileInputStream input = null; // Try to open local file for reading try { input = new FileInputStream(localFilename); } catch (IOException e) { tftp.close(); System.err.println("Error: could not open local file for reading."); System.err.println(e.getMessage()); System.exit(1); } // Try to send local file via TFTP try { tftp.sendFile(remoteFilename, transferMode, input, hostname); } catch (UnknownHostException e) { System.err.println("Error: could not resolve hostname."); System.err.println(e.getMessage()); System.exit(1); } catch (IOException e) { System.err.println("Error: I/O exception occurred while sending file."); System.err.println(e.getMessage()); System.exit(1); } finally { // Close local socket and input file tftp.close(); try { input.close(); closed = true; } catch (IOException e) { closed = false; System.err.println("Error: error closing file."); System.err.println(e.getMessage()); } } if (!closed) System.exit(1); } }
From source file:examples.tftp.java
public final static void main(String[] args) { boolean receiveFile = true, closed; int transferMode = TFTP.BINARY_MODE, argc; String arg, hostname, localFilename, remoteFilename; TFTPClient tftp; // Parse options for (argc = 0; argc < args.length; argc++) { arg = args[argc];/*from w w w .ja v a 2 s . c o m*/ if (arg.startsWith("-")) { if (arg.equals("-r")) receiveFile = true; else if (arg.equals("-s")) receiveFile = false; else if (arg.equals("-a")) transferMode = TFTP.ASCII_MODE; else if (arg.equals("-b")) transferMode = TFTP.BINARY_MODE; else { System.err.println("Error: unrecognized option."); System.err.print(USAGE); System.exit(1); } } else break; } // Make sure there are enough arguments if (args.length - argc != 3) { System.err.println("Error: invalid number of arguments."); System.err.print(USAGE); System.exit(1); } // Get host and file arguments hostname = args[argc]; localFilename = args[argc + 1]; remoteFilename = args[argc + 2]; // Create our TFTP instance to handle the file transfer. tftp = new TFTPClient(); // We want to timeout if a response takes longer than 60 seconds tftp.setDefaultTimeout(60000); // Open local socket try { tftp.open(); } catch (SocketException e) { System.err.println("Error: could not open local UDP socket."); System.err.println(e.getMessage()); System.exit(1); } // We haven't closed the local file yet. closed = false; // If we're receiving a file, receive, otherwise send. if (receiveFile) { FileOutputStream output = null; File file; file = new File(localFilename); // If file exists, don't overwrite it. if (file.exists()) { System.err.println("Error: " + localFilename + " already exists."); System.exit(1); } // Try to open local file for writing try { output = new FileOutputStream(file); } catch (IOException e) { tftp.close(); System.err.println("Error: could not open local file for writing."); System.err.println(e.getMessage()); System.exit(1); } // Try to receive remote file via TFTP try { tftp.receiveFile(remoteFilename, transferMode, output, hostname); } catch (UnknownHostException e) { System.err.println("Error: could not resolve hostname."); System.err.println(e.getMessage()); System.exit(1); } catch (IOException e) { System.err.println("Error: I/O exception occurred while receiving file."); System.err.println(e.getMessage()); System.exit(1); } finally { // Close local socket and output file tftp.close(); try { output.close(); closed = true; } catch (IOException e) { closed = false; System.err.println("Error: error closing file."); System.err.println(e.getMessage()); } } if (!closed) System.exit(1); } else { // We're sending a file FileInputStream input = null; // Try to open local file for reading try { input = new FileInputStream(localFilename); } catch (IOException e) { tftp.close(); System.err.println("Error: could not open local file for reading."); System.err.println(e.getMessage()); System.exit(1); } // Try to send local file via TFTP try { tftp.sendFile(remoteFilename, transferMode, input, hostname); } catch (UnknownHostException e) { System.err.println("Error: could not resolve hostname."); System.err.println(e.getMessage()); System.exit(1); } catch (IOException e) { System.err.println("Error: I/O exception occurred while sending file."); System.err.println(e.getMessage()); System.exit(1); } finally { // Close local socket and input file tftp.close(); try { input.close(); closed = true; } catch (IOException e) { closed = false; System.err.println("Error: error closing file."); System.err.println(e.getMessage()); } } if (!closed) System.exit(1); } }
From source file:TFTPExample.java
public static void main(String[] args) { boolean receiveFile = true, closed; int transferMode = TFTP.BINARY_MODE, argc; String arg, hostname, localFilename, remoteFilename; TFTPClient tftp; // Parse options for (argc = 0; argc < args.length; argc++) { arg = args[argc];//from w ww . j ava 2 s . com if (arg.startsWith("-")) { if (arg.equals("-r")) { receiveFile = true; } else if (arg.equals("-s")) { receiveFile = false; } else if (arg.equals("-a")) { transferMode = TFTP.ASCII_MODE; } else if (arg.equals("-b")) { transferMode = TFTP.BINARY_MODE; } else { System.err.println("Error: unrecognized option."); System.err.print(USAGE); System.exit(1); } } else { break; } } // Make sure there are enough arguments if (args.length - argc != 3) { System.err.println("Error: invalid number of arguments."); System.err.print(USAGE); System.exit(1); } // Get host and file arguments hostname = args[argc]; localFilename = args[argc + 1]; remoteFilename = args[argc + 2]; // Create our TFTP instance to handle the file transfer. tftp = new TFTPClient(); // We want to timeout if a response takes longer than 60 seconds tftp.setDefaultTimeout(60000); // Open local socket try { tftp.open(); } catch (SocketException e) { System.err.println("Error: could not open local UDP socket."); System.err.println(e.getMessage()); System.exit(1); } // We haven't closed the local file yet. closed = false; // If we're receiving a file, receive, otherwise send. if (receiveFile) { FileOutputStream output = null; File file; file = new File(localFilename); // If file exists, don't overwrite it. if (file.exists()) { System.err.println("Error: " + localFilename + " already exists."); System.exit(1); } // Try to open local file for writing try { output = new FileOutputStream(file); } catch (IOException e) { tftp.close(); System.err.println("Error: could not open local file for writing."); System.err.println(e.getMessage()); System.exit(1); } // Try to receive remote file via TFTP try { tftp.receiveFile(remoteFilename, transferMode, output, hostname); } catch (UnknownHostException e) { System.err.println("Error: could not resolve hostname."); System.err.println(e.getMessage()); System.exit(1); } catch (IOException e) { System.err.println("Error: I/O exception occurred while receiving file."); System.err.println(e.getMessage()); System.exit(1); } finally { // Close local socket and output file tftp.close(); try { if (output != null) { output.close(); } closed = true; } catch (IOException e) { closed = false; System.err.println("Error: error closing file."); System.err.println(e.getMessage()); } } if (!closed) { System.exit(1); } } else { // We're sending a file FileInputStream input = null; // Try to open local file for reading try { input = new FileInputStream(localFilename); } catch (IOException e) { tftp.close(); System.err.println("Error: could not open local file for reading."); System.err.println(e.getMessage()); System.exit(1); } // Try to send local file via TFTP try { tftp.sendFile(remoteFilename, transferMode, input, hostname); } catch (UnknownHostException e) { System.err.println("Error: could not resolve hostname."); System.err.println(e.getMessage()); System.exit(1); } catch (IOException e) { System.err.println("Error: I/O exception occurred while sending file."); System.err.println(e.getMessage()); System.exit(1); } finally { // Close local socket and input file tftp.close(); try { if (input != null) { input.close(); } closed = true; } catch (IOException e) { closed = false; System.err.println("Error: error closing file."); System.err.println(e.getMessage()); } } if (!closed) { System.exit(1); } } }
From source file:com.xiangzhurui.util.ftp.TFTPExample.java
public static void main(String[] args) { boolean receiveFile = true, closed; int transferMode = TFTP.BINARY_MODE, argc; String arg, hostname, localFilename, remoteFilename; TFTPClient tftp; // Parse options for (argc = 0; argc < args.length; argc++) { arg = args[argc];/* w w w . j a v a 2s . c o m*/ if (arg.startsWith("-")) { if (arg.equals("-r")) { receiveFile = true; } else if (arg.equals("-s")) { receiveFile = false; } else if (arg.equals("-a")) { transferMode = TFTP.ASCII_MODE; } else if (arg.equals("-b")) { transferMode = TFTP.BINARY_MODE; } else { System.err.println("Error: unrecognized option."); System.err.print(USAGE); System.exit(1); } } else { break; } } // Make sure there are enough arguments if (args.length - argc != 3) { System.err.println("Error: invalid number of arguments."); System.err.print(USAGE); System.exit(1); } // Get host and file arguments hostname = args[argc]; localFilename = args[argc + 1]; remoteFilename = args[argc + 2]; // Create our TFTP instance to handle the file transfer. tftp = new TFTPClient(); // We want to timeout if a response takes longer than 60 seconds tftp.setDefaultTimeout(60000); // Open local socket try { tftp.open(); } catch (SocketException e) { System.err.println("Error: could not open local UDP socket."); System.err.println(e.getMessage()); System.exit(1); } // We haven't closed the local file yet. closed = false; // If we're receiving a file, receive, otherwise send. if (receiveFile) { FileOutputStream output = null; File file; file = new File(localFilename); // If file exists, don't overwrite it. if (file.exists()) { System.err.println("Error: " + localFilename + " already exists."); System.exit(1); } // Try to open local file for writing try { output = new FileOutputStream(file); } catch (IOException e) { tftp.close(); System.err.println("Error: could not open local file for writing."); System.err.println(e.getMessage()); System.exit(1); } // Try to receive remote file via TFTP try { tftp.receiveFile(remoteFilename, transferMode, output, hostname); } catch (UnknownHostException e) { System.err.println("Error: could not resolve hostname."); System.err.println(e.getMessage()); System.exit(1); } catch (IOException e) { System.err.println("Error: I/O exception occurred while receiving file."); System.err.println(e.getMessage()); System.exit(1); } finally { // Close local socket and output file tftp.close(); try { if (output != null) { output.close(); } closed = true; } catch (IOException e) { closed = false; System.err.println("Error: error closing file."); System.err.println(e.getMessage()); } } if (!closed) { System.exit(1); } } else { // We're sending a file FileInputStream input = null; // Try to open local file for reading try { input = new FileInputStream(localFilename); } catch (IOException e) { tftp.close(); System.err.println("Error: could not open local file for reading."); System.err.println(e.getMessage()); System.exit(1); } // Try to send local file via TFTP try { tftp.sendFile(remoteFilename, transferMode, input, hostname); } catch (UnknownHostException e) { System.err.println("Error: could not resolve hostname."); System.err.println(e.getMessage()); System.exit(1); } catch (IOException e) { System.err.println("Error: I/O exception occurred while sending file."); System.err.println(e.getMessage()); System.exit(1); } finally { // Close local socket and input file tftp.close(); try { if (input != null) { input.close(); } closed = true; } catch (IOException e) { closed = false; System.err.println("Error: error closing file."); System.err.println(e.getMessage()); } } if (!closed) { System.exit(1); } } }
From source file:com.t_oster.liblasercut.drivers.LaosCutter.java
@Override public void sendJob(LaserJob job, ProgressListener pl, List<String> warnings) throws IllegalJobException, Exception { currentFrequency = -1;/*from w ww . j a v a 2 s . c o m*/ currentPower = -1; currentSpeed = -1; currentFocus = 0; currentPurge = false; currentVentilation = false; pl.progressChanged(this, 0); BufferedOutputStream out; ByteArrayOutputStream buffer = null; pl.taskChanged(this, "checking job"); checkJob(job); job.applyStartPoint(); if (!useTftp) { pl.taskChanged(this, "connecting"); Socket connection = new Socket(); connection.connect(new InetSocketAddress(hostname, port), 3000); out = new BufferedOutputStream(connection.getOutputStream()); pl.taskChanged(this, "sending"); } else { buffer = new ByteArrayOutputStream(); out = new BufferedOutputStream(buffer); pl.taskChanged(this, "buffering"); } this.writeJobCode(job, out, pl); if (this.isUseTftp()) { pl.taskChanged(this, "connecting"); TFTPClient tftp = new TFTPClient(); tftp.setDefaultTimeout(5000); //open a local UDP socket tftp.open(); pl.taskChanged(this, "sending"); ByteArrayInputStream bain = new ByteArrayInputStream(buffer.toByteArray()); tftp.sendFile(job.getName().replace(" ", "") + ".lgc", TFTP.BINARY_MODE, bain, this.getHostname(), this.getPort()); tftp.close(); bain.close(); if (debugFilename != null && !"".equals(debugFilename)) { pl.taskChanged(this, "writing " + debugFilename); FileOutputStream o = new FileOutputStream(new File(debugFilename)); o.write(buffer.toByteArray()); o.close(); } pl.taskChanged(this, "sent."); } pl.progressChanged(this, 100); }
From source file:org.apache.common.net.examples.ftp.TFTPExample.java
public final static void main(String[] args) { boolean receiveFile = true, closed; int transferMode = TFTP.BINARY_MODE, argc; String arg, hostname, localFilename, remoteFilename; TFTPClient tftp; // Parse options for (argc = 0; argc < args.length; argc++) { arg = args[argc];//from www. j ava 2 s . c o m if (arg.startsWith("-")) { if (arg.equals("-r")) { receiveFile = true; } else if (arg.equals("-s")) { receiveFile = false; } else if (arg.equals("-a")) { transferMode = TFTP.ASCII_MODE; } else if (arg.equals("-b")) { transferMode = TFTP.BINARY_MODE; } else { System.err.println("Error: unrecognized option."); System.err.print(USAGE); System.exit(1); } } else { break; } } // Make sure there are enough arguments if (args.length - argc != 3) { System.err.println("Error: invalid number of arguments."); System.err.print(USAGE); System.exit(1); } // Get host and file arguments hostname = args[argc]; localFilename = args[argc + 1]; remoteFilename = args[argc + 2]; // Create our TFTP instance to handle the file transfer. tftp = new TFTPClient(); // We want to timeout if a response takes longer than 60 seconds tftp.setDefaultTimeout(60000); // Open local socket try { tftp.open(); } catch (SocketException e) { System.err.println("Error: could not open local UDP socket."); System.err.println(e.getMessage()); System.exit(1); } // We haven't closed the local file yet. closed = false; // If we're receiving a file, receive, otherwise send. if (receiveFile) { FileOutputStream output = null; File file; file = new File(localFilename); // If file exists, don't overwrite it. if (file.exists()) { System.err.println("Error: " + localFilename + " already exists."); System.exit(1); } // Try to open local file for writing try { output = new FileOutputStream(file); } catch (IOException e) { tftp.close(); System.err.println("Error: could not open local file for writing."); System.err.println(e.getMessage()); System.exit(1); } // Try to receive remote file via TFTP try { tftp.receiveFile(remoteFilename, transferMode, output, hostname); } catch (UnknownHostException e) { System.err.println("Error: could not resolve hostname."); System.err.println(e.getMessage()); System.exit(1); } catch (IOException e) { System.err.println("Error: I/O exception occurred while receiving file."); System.err.println(e.getMessage()); System.exit(1); } finally { // Close local socket and output file tftp.close(); try { if (output != null) { output.close(); } closed = true; } catch (IOException e) { closed = false; System.err.println("Error: error closing file."); System.err.println(e.getMessage()); } } if (!closed) { System.exit(1); } } else { // We're sending a file FileInputStream input = null; // Try to open local file for reading try { input = new FileInputStream(localFilename); } catch (IOException e) { tftp.close(); System.err.println("Error: could not open local file for reading."); System.err.println(e.getMessage()); System.exit(1); } // Try to send local file via TFTP try { tftp.sendFile(remoteFilename, transferMode, input, hostname); } catch (UnknownHostException e) { System.err.println("Error: could not resolve hostname."); System.err.println(e.getMessage()); System.exit(1); } catch (IOException e) { System.err.println("Error: I/O exception occurred while sending file."); System.err.println(e.getMessage()); System.exit(1); } finally { // Close local socket and input file tftp.close(); try { if (input != null) { input.close(); } closed = true; } catch (IOException e) { closed = false; System.err.println("Error: error closing file."); System.err.println(e.getMessage()); } } if (!closed) { System.exit(1); } } }
From source file:org.apache.commons.net.examples.ftp.TFTPExample.java
public static void main(String[] args) { boolean receiveFile = true, closed; int transferMode = TFTP.BINARY_MODE, argc; String arg, hostname, localFilename, remoteFilename; final TFTPClient tftp; int timeout = 60000; boolean verbose = false; // Parse options for (argc = 0; argc < args.length; argc++) { arg = args[argc];//from w w w . java 2 s .com if (arg.startsWith("-")) { if (arg.equals("-r")) { receiveFile = true; } else if (arg.equals("-s")) { receiveFile = false; } else if (arg.equals("-a")) { transferMode = TFTP.ASCII_MODE; } else if (arg.equals("-b")) { transferMode = TFTP.BINARY_MODE; } else if (arg.equals("-t")) { timeout = 1000 * Integer.parseInt(args[++argc]); } else if (arg.equals("-v")) { verbose = true; } else { System.err.println("Error: unrecognized option."); System.err.print(USAGE); System.exit(1); } } else { break; } } // Make sure there are enough arguments if (args.length - argc != 3) { System.err.println("Error: invalid number of arguments."); System.err.print(USAGE); System.exit(1); } // Get host and file arguments hostname = args[argc]; localFilename = args[argc + 1]; remoteFilename = args[argc + 2]; // Create our TFTP instance to handle the file transfer. if (verbose) { tftp = new TFTPClient() { @Override protected void trace(String direction, TFTPPacket packet) { System.out.println(direction + " " + packet); } }; } else { tftp = new TFTPClient(); } // We want to timeout if a response takes longer than 60 seconds tftp.setDefaultTimeout(timeout); // We haven't closed the local file yet. closed = false; // If we're receiving a file, receive, otherwise send. if (receiveFile) { closed = receive(transferMode, hostname, localFilename, remoteFilename, tftp); } else { // We're sending a file closed = send(transferMode, hostname, localFilename, remoteFilename, tftp); } System.out.println("Recd: " + tftp.getTotalBytesReceived() + " Sent: " + tftp.getTotalBytesSent()); if (!closed) { System.out.println("Failed"); System.exit(1); } System.out.println("OK"); }
From source file:org.sipfoundry.preflight.TFTP.java
public ResultCode validate(int timeout, NetworkResources networkResources, JournalService journalService, InetAddress bindAddress) { ResultCode results = NONE;/* w ww . j a v a 2 s . co m*/ InetAddress tftpServerAddress = null; String testFile = new String("00D01EFFFFFE"); String[] verificationStrings = { "LIP-68XX configuration information", "[VOIP]", "outbound_proxy_server", "[PROVISION]", "decrypt_key" }; if (networkResources.configServer == null) { journalService.println("No TFTP server provided, skipping test.\n"); return CONFIG_SERVER_MISSING; } journalService.println("Starting TFTP server test."); TFTPClient tftp = new TFTPClient(); tftp.setDefaultTimeout(timeout * 1000); if (IPAddressUtil.isLiteralIPAddress(networkResources.configServer)) { try { tftpServerAddress = InetAddress.getByName(networkResources.configServer); } catch (UnknownHostException e) { // Should never get here. e.printStackTrace(); } journalService.println("Using TFTP server literal address: " + networkResources.configServer); } else { // Try to retrieve A RECORD for TFTP server, checking each DNS server. SimpleResolver resolver = null; try { resolver = new SimpleResolver(); resolver.setTimeout(timeout); } catch (UnknownHostException e) { e.printStackTrace(); } for (InetAddress dnsServer : networkResources.domainNameServers) { journalService.println( "Looking up TFTP server address via DNS server: " + dnsServer.getCanonicalHostName()); String targetMessage = new String( " TFTP server address \"" + networkResources.configServer + "\""); resolver.setAddress(dnsServer); Lookup aLookup = null; try { aLookup = new Lookup(networkResources.configServer, Type.A); } catch (TextParseException e) { journalService.println(" is malformed.\n"); journalService.println(targetMessage); return TFTP_ADDRESS_MALFORMED; } aLookup.setResolver(resolver); Record[] aRecords = aLookup.run(); switch (aLookup.getResult()) { case Lookup.SUCCESSFUL: if (aRecords != null) { InetAddress targetAddress = ((ARecord) aRecords[0]).getAddress(); targetMessage += " resolves to: " + targetAddress.getHostAddress(); journalService.println(targetMessage); if (tftpServerAddress == null) { tftpServerAddress = targetAddress; } else { // Check that multiple lookups result in same address. if (!tftpServerAddress.equals(targetAddress)) { journalService.println(" TFTP server address does not match prior lookup."); results = MULTIPLE_CONFIG_TARGETS; } } } else { targetMessage += " could not be resolved."; journalService.println(targetMessage); results = TFTP_TARGET_UNRESOLVED; } break; case Lookup.UNRECOVERABLE: targetMessage += " [Unrecoverable error]"; journalService.println(targetMessage); results = TFTP_TARGET_UNRESOLVED; break; case Lookup.TRY_AGAIN: targetMessage += " [Lookup timeout]"; journalService.println(targetMessage); results = TFTP_TARGET_UNRESOLVED; break; case Lookup.HOST_NOT_FOUND: targetMessage += " could not be resolved."; journalService.println(targetMessage); results = TFTP_TARGET_UNRESOLVED; break; case Lookup.TYPE_NOT_FOUND: targetMessage += " could not be resolved."; journalService.println(targetMessage); results = TFTP_TARGET_UNRESOLVED; break; } } } if ((tftpServerAddress == null) || (results == MULTIPLE_CONFIG_TARGETS)) { journalService.println("Cannot recover from previous errors, aborting TFTP test.\n"); return results; } journalService.println("Beginning TFTP get request of test file: " + testFile); // Open local socket try { tftp.open(); } catch (SocketException e) { journalService.println("TFTP client failure. " + e.getMessage() + "\n"); return TFTP_CLIENT_FAILURE; } // Try to receive remote file via TFTP try { ByteArrayOutputStream output = new ByteArrayOutputStream(); tftp.open(bindPort, bindAddress); tftp.receiveFile(testFile, org.apache.commons.net.tftp.TFTP.ASCII_MODE, output, tftpServerAddress); String testFileContents = output.toString(); boolean verified = true; for (String verificationString : verificationStrings) { if (!testFileContents.contains(verificationString)) { verified = false; } } if (verified) { journalService.println("File received successfully."); } else { journalService.println("File received but contents do not verify."); results = TFTP_CONTENTS_FAILED; } } catch (UnknownHostException e) { journalService.println("TFTP client failure. " + e.getMessage()); results = TFTP_CLIENT_FAILURE; } catch (IOException e) { journalService.println("TFTP get failed. " + e.getMessage()); results = TFTP_GET_FAILED; } finally { // Close local socket and output file tftp.close(); } journalService.println(""); return results; }