tracywong117/Run-Docker-Testing
0
1// YourJavaProgram.java2 3import java.io.FileWriter;4import java.io.IOException;5 6public class YourJavaProgram {7 public static void main(String[] args) {8 // Check if the input argument is provided9 if (args.length < 1) {10 System.out.println("Please provide an input argument.");11 return;12 }13 14 // Parse the input argument as an integer15 int number;16 try {17 number = Integer.parseInt(args[0]);18 } catch (NumberFormatException e) {19 System.out.println("Invalid input argument. Please provide an integer.");20 return;21 }22 23 // Perform some operation or computation24 int result = number * 2;25 26 // Create a file writer for the output file27 try (FileWriter writer = new FileWriter("output.txt")) {28 // Write the result to the output file29 writer.write(String.valueOf(result));30 } catch (IOException e) {31 e.printStackTrace();32 }33 }34}