Java로 windows redirection 할 때 "지정된 파일을 찾을 수 없습니다" 문제에 대한 것입니다.

qeeeeep의 이미지

윈도우즈 콘솔에서 자바 프로그램 Test.class를 실행시킬 때
표준 입출력을 파일 입출력으로 대신하는 redirection을 사용하고 싶습니다.

하지만 콘솔창에서
"java Test < input.txt > output.txt"
형식으로 프로그램을 실행하면
"지정된 파일을 찾을 수 없습니다" 라는 에러가 나옵니다.
분명 Test.class와 input.txt 모두 존재합니다.

어떻게 해결할 수 있을까요?

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Scanner;
 
public class Test {
 
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner scanner = null;
		BufferedWriter out = null;
		try {
			scanner = new Scanner(System.in);
			out = new BufferedWriter(new OutputStreamWriter(System.out));
 
			int caseNum = 0;
			if(scanner.hasNextInt()) {
				caseNum = scanner.nextInt();
			} else {
				return;
			}
 
			int x = 0;
 
			for(int i = 0; i < caseNum; i++) {
				if(scanner.hasNextInt()) {
					x = scanner.nextInt();
				} else {
					return;
				}
 
				// x를 절댓값으로 변환
				x = Math.abs(x);
 
				int n = 0;
				int sumOfN = 0;
				while(true) {
 
					if(n == x) {
						break;
					}
					sumOfN += n;
					if(x < sumOfN && (sumOfN-x)%2 == 0) {
						break;
					}
					n++;
				}
 
				// 파일 출력
				out.write(String.valueOf(n)); out.newLine();
			}
			out.flush();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}
File attachments: 
첨부파일 크기
Image icon redirection error.png79.79 KB