I have written a java code which is working perfectly when I am executing locally. But gives out of memory exception when invoked from informatica. I am reading a file and splitting the contents and replacing the contents of the same file.
public static void main(String[] args) throws IOException {
String delims = "#@#@#";
StringBuilder sb=null;
String filepath = "FILE_PATH";
try {
FileReader in = new FileReader(filepath);
BufferedReader br = new BufferedReader(in);
sb= new StringBuilder();
sb.append(br.readLine());
in.close();
}
catch (Exception ex) {
}
StringTokenizer st = new StringTokenizer(sb.toString(), delims);
try {
FileWriter fw = new FileWriter(filepath, false);
while (st.hasMoreElements()) {
fw.write(st.nextToken() + System.getProperty("line.separator"));
}
fw.flush();
fw.close();
} catch (Exception ex) {
}
}
Now, the exception occurs while reading the contents of a big data file. For small data files, it is working fine.