sibindon's blog

By sibindon, history, 6 weeks ago, In English

I wanted to take input from a file and print output to another file. I am able to take the input successfully(Tested using System.out) but there is no output on the output file.

import java.util.*;

class a{

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	public a() throws Exception{
		if (System.getProperty("ONLINE_JUDGE") == null) {
			br = new BufferedReader(new FileReader("input.txt"));
			out = new PrintWriter(new FileWriter("output.txt"));
		else {
			br = new BufferedReader(new InputStreamReader(;
			out = new PrintWriter(System.out);

	public void solve() throws IOException{
		int n = Integer.parseInt(br.readLine());

	public static void main(String[] args) throws Exception{
		new a().solve();
  • Vote: I like it
  • 0
  • Vote: I do not like it