This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-net.git

commit 7cc306f2def4114fe091620adf1178e9e109a6f6
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Fri Jun 23 09:13:42 2023 -0400

    Clean up exception handling in example
---
 .../org/apache/commons/net/examples/ftp/TFTPExample.java    | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/net/examples/ftp/TFTPExample.java 
b/src/main/java/org/apache/commons/net/examples/ftp/TFTPExample.java
index 19b3424b..c5dbe7d1 100644
--- a/src/main/java/org/apache/commons/net/examples/ftp/TFTPExample.java
+++ b/src/main/java/org/apache/commons/net/examples/ftp/TFTPExample.java
@@ -61,7 +61,7 @@ public final class TFTPExample {
         return closed;
     }
 
-    public static void main(final String[] args) {
+    public static void main(final String[] args) throws IOException {
         boolean receiveFile = true, closed;
         int transferMode = TFTP.BINARY_MODE, argc;
         String arg;
@@ -145,16 +145,16 @@ public final class TFTPExample {
         System.out.println("OK");
     }
 
-    private static void open(final TFTPClient tftp) {
+    private static void open(final TFTPClient tftp) throws IOException {
         try {
             tftp.open();
         } catch (final SocketException e) {
-            throw new RuntimeException("Error: could not open local UDP 
socket.", e);
+            throw new IOException("Error: could not open local UDP socket.", 
e);
         }
     }
 
     private static boolean receive(final int transferMode, final String 
hostname, final String localFilename, final String remoteFilename,
-            final TFTPClient tftp) {
+            final TFTPClient tftp) throws IOException {
         final boolean closed;
         FileOutputStream output;
         final File file;
@@ -172,7 +172,7 @@ public final class TFTPExample {
             output = new FileOutputStream(file);
         } catch (final IOException e) {
             tftp.close();
-            throw new RuntimeException("Error: could not open local file for 
writing.", e);
+            throw new IOException("Error: could not open local file for 
writing.", e);
         }
 
         open(tftp);
@@ -201,7 +201,8 @@ public final class TFTPExample {
         return closed;
     }
 
-    private static boolean send(final int transferMode, final String hostname, 
final String localFilename, final String remoteFilename, final TFTPClient tftp) 
{
+    private static boolean send(final int transferMode, final String hostname, 
final String localFilename, final String remoteFilename, final TFTPClient tftp)
+            throws IOException {
         final boolean closed;
         FileInputStream input;
 

Reply via email to