Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
InputChecker of problemA in WUPC2nd.
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStreamReader;
public class InputCheckerA {
public static void main(String[] args) throws Exception {
File inputDir = new File("/path/to/the/input/files/directory");
for (File file : inputDir.listFiles()) {
BufferedReader reader = new BufferedReader(new FileReader(file));
if (!check(reader)) {
System.err.println("err:" + file.getName());
} else {
System.err.println("ok");
}
reader.close();
}
}
private static boolean check(BufferedReader reader) {
try {
String line = reader.readLine();
String[] data = line.split(" ");
if (data.length != 2) {
return false;
}
int N = Integer.valueOf(data[0]);
int M = Integer.valueOf(data[1]);
if (1 <= N && N <= 100) {
if (1 <= M && M <= 100) {
return true;
}
}
} catch (Exception e) {
return false;
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment