Submitting solution with Input/Output from external file

While submitting solutions to Online Judges like CC, CF, or any other coding competitions online like Facebook Hacker Cup, Google Code Jam, should I put the following code in comments or leave it as it is in C++?

#ifndef ONLINE_JUDGE

    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);

#endif

Also in Java, if use FileReader and PrintWriter to read and write from external files, and to print should I change

BufferedReader br = new BufferedReader( new FileReader("input.txt")); 
PrintWriter pw=new PrintWriter(new BufferedWriter(new FileWriter("output.txt"))); 

to

BufferedReader br = new BufferedReader( new InputStreamReader(System.in));

and also change    pw.wrtie()    to    System.out.print()    ?