JAVA重定向输入输出
没什么好说的,直接贴代码了。
1 import java.io.*; 2 import java.util.*; 3 4 public class Main { 5 public static void main(String[] args) throws IOException { 6 System.setIn(new BufferedInputStream(new FileInputStream("ride.in"))); 7 System.setOut(new PrintStream(new FileOutputStream("ride.out"))); 8 9 Scanner cin = new Scanner(System.in); 10 while(cin.hasNext()){ 11 // do staff... 12 } 13 } 14 }