Skip to content

Commit

Permalink
Fixes java hello world app to read from stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
nmisek committed Oct 30, 2024
1 parent 7a93147 commit 72f0fdb
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions java-hello-world/src/main/java/com/nextmv/example/Main.java
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
package com.nextmv.example;

import com.google.gson.Gson;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.IOException;
import com.google.gson.JsonObject;

public class Main {
public static void main(String[] args) {
Gson gson = new Gson();


try (FileReader reader = new FileReader("input.json")) {
// Read from stdin.
Input input = gson.fromJson(reader, Input.class);
public static void main(String[] args) {
Gson gson = new Gson();

try (InputStreamReader reader = new InputStreamReader(System.in)) {
// Read from stdin.
Input input = gson.fromJson(reader, Input.class);

// ##### Insert model here

// Print logs that render in the run view in Nextmv Console
System.err.println("Hello, " + input.name);

// Write output and statistics.
Output output = new Output(input.name);
Output.write(output);
} catch (IOException e) {
e.printStackTrace();
}
}
// ##### Insert model here
// Print logs that render in the run view in Nextmv Console
System.err.println("Hello, " + input.name);
// Write output and statistics.
Output output = new Output(input.name);
Output.write(output);
} catch (IOException e) {
e.printStackTrace();
}
}
}


class Input {
String name;
}
Expand Down

0 comments on commit 72f0fdb

Please sign in to comment.