title: How to make my java program run faster?
body: <p>This program runs in 0.099s on my device. I want to run it in less than 0.01s. How to make this happen. Its probably related to the reading and writing stream. This progam basically takes in a string and performs some operations on the characters of the string one by one in the method calc and returns some int value. You don't really need to understand the code. The optimizations if any has to take happen with the i/o stream or inside the method. I can't think of any other place where this optimization needs to happen.</p>
  
  <pre><code>import java.io.*;
  import java.util.*;
  
  class ride{
  static int calc(String s){
  char[] d=new char[s.length()];
  s.getChars(0,s.length(),d,0);
  int sum=1;
  for(char c:d){
  sum*=(c-'A'+1);
  }
  return sum%47;
  }
  
  
  
  public static void main(String args[]){
  try{
  BufferedReader br=new BufferedReader(new FileReader("ride.in"));
  FileWriter fw=new FileWriter("ride.out");
  String s;
  while((s=br.readLine())!=null){
  if(calc(s)==calc(br.readLine())){
  fw.write("GO\n");
  }
  else
  fw.write("STAY\n");
  }
  fw.close();
  }
  catch(IOException e){
  System.out.println(e);
  }
  }
  }
  </code></pre>