File size: 1,041 Bytes
9543229
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// YourJavaProgram.java

import java.io.FileWriter;
import java.io.IOException;

public class YourJavaProgram {
    public static void main(String[] args) {
        // Check if the input argument is provided
        if (args.length < 1) {
            System.out.println("Please provide an input argument.");
            return;
        }
        
        // Parse the input argument as an integer
        int number;
        try {
            number = Integer.parseInt(args[0]);
        } catch (NumberFormatException e) {
            System.out.println("Invalid input argument. Please provide an integer.");
            return;
        }
        
        // Perform some operation or computation
        int result = number * 2;
        
        // Create a file writer for the output file
        try (FileWriter writer = new FileWriter("output.txt")) {
            // Write the result to the output file
            writer.write(String.valueOf(result));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}