Is there such this function in b4j ? BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
B4X:
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Hello {
public static void main(String[] args) {
@SuppressWarnings("WeakerAccess")
class Result {
public String topic;
public String payload;
}
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
//noinspection InfiniteLoopStatement
for (;;) {
try {
String line = stdin.readLine();
JSONObject obj = JSON.parseObject(line);
String payload = obj.get("payload").toString();
Result result = new Result();
result.topic = "Log";
result.payload = "输入的payload=" + payload; // this line contains Chinese characters.
System.out.print("it works"); // the output will be parsed line by line,
Thread.sleep(200); // no matter timing.
System.out.println(" fine!"); // this will be shown on node-red console but not to output
// because it it not a valid JSON string.
System.out.println(JSON.toJSONString(result,
// with unicode, Chinese characters can be displayed correctly.
SerializerFeature.BrowserCompatible // BrowserCompatible ==> unicode encoding.
)); // this message will appear at the output of this node.
System.out.println("This is a Java program."); // only to node-red console
} catch (Exception e) {
e.printStackTrace();
}
}
}
}