Internet ip logger

java Java
/*
 * @author charles66820
 *
 * javac InternetIp.java
 * jar -e InternetIp -c -v -f internetIp.jar InternetIp.class
 */
import java.io.*;
import java.net.URL;
import java.util.Date;
import java.text.SimpleDateFormat;

public class InternetIp {
  private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ");

  public static void main(String[] args) {
    BufferedReader in = null;
    String ip = null;
    try {
      // Create ip request
      URL whatismyip = new URL("http://checkip.amazonaws.com");
      in = new BufferedReader(new InputStreamReader(whatismyip.openStream()));
      ip = in.readLine();
    } catch (Exception e) {
      System.out.println("Error on Get ip");
    } finally {
        try {
          if (in != null) in.close();
        } catch (IOException e) {
          System.out.println("Error on close ip request");
        }
    }

    // Print ip in file
    try (PrintWriter outip = new PrintWriter(new FileWriter("internetNodeIp.log", true))) {
      outip.format("[%s] : %s\n", dateFormat.format(new Date()), ip);
    } catch (Exception e) {
      System.out.println("Error on print ip in file");
    }
  }
}
[2021-04-24 23:47:00+0200] : 12.345.67.89