Java I/O Query

Правка en1, от Sibin_Thomas, 2020-09-21 16:45:35

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.*;
import java.io.*;

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(System.in));
			out = new PrintWriter(System.out);
		}
	}

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

	public static void main(String[] args) throws Exception{
		new a().solve();
	}
}

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Sibin_Thomas 2020-09-21 16:45:35 871 Initial revision (published)