どう書くんだっけ?となるのでメモ
Java
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Sample{
public static void main(String[] args){
try{
System.out.println("[START]");
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String line;
System.out.print("[IN]:");
while((line = reader.readLine()) != null){
System.out.println("[OUT]:"+line);
System.out.print("[IN]:");
}
reader.close();
System.out.println("[END]");
}catch(Exception e){
e.printStackTrace();
System.exit(-1);
}
}
}
Python
import signal
print('exit: Ctrl + c')
def handler(signal, frame):
exit()
signal.signal(signal.SIGINT, handler)
while True:
pass
input_msg = input('[input_msg]:')
if input_msg == '':
continue
output_msg = '[output_msg]:' + input_msg
print(output_msg)
PHP
<?php
print("exit: Ctrl + c" . PHP_EOL);
while(true) {
print('[input_msg]:');
$input_msg = trim(fgets(STDIN));
if($input_msg == ''){ continue; }
$output_msg = "[output_msg]:" . $input_msg;
print($output_msg . PHP_EOL);
}