|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
File processing please help!
Hello,
I know this is not server-side topic, but perhaps someone could help me. I am trying a file-processing with a large file (50 mb). The File is splitted according to a condition in the if clauses and the different rows should be written to 9 target files. Here's the code: public void splitData (String source1, String t00, String t10,String t20,String t30,String t40,String t50,String t60,String t70,String t80) { String line; BufferedWriter t0,t1,t2,t3,t4,t5,t6,t7,t8; BufferedReader s; try { s = new BufferedReader(new FileReader(source1)); t0 = new BufferedWriter(new FileWriter(t00)); t1 = new BufferedWriter(new FileWriter(t10)); t2 = new BufferedWriter(new FileWriter(t20)); t3 = new BufferedWriter(new FileWriter(t30)); t4 = new BufferedWriter(new FileWriter(t40)); t5 = new BufferedWriter(new FileWriter(t50)); t6 = new BufferedWriter(new FileWriter(t60)); t7 = new BufferedWriter(new FileWriter(t70)); t8 = new BufferedWriter(new FileWriter(t80)); System.out.println("Splitting file..."+source1); int total=0; // long anfang = System.currentTimeMillis(); while ((line = s.readLine()) != null) { if ((line.substring(70,72)).equals("00")) {t0.write(line);t0.newLine();} if ((line.substring(70,72)).equals("10")) {t1.write(line);t1.newLine();} if ((line.substring(70,72)).equals("20")) {t2.write(line);t2.newLine();} if ((line.substring(70,72)).equals("30")) {t3.write(line);t3.newLine();} if ((line.substring(70,72)).equals("40")) {t4.write(line);t4.newLine();} if ((line.substring(70,72)).equals("50")) {t5.write(line);t5.newLine();} if ((line.substring(70,72)).equals("60")) {t6.write(line);t6.newLine();} if ((line.substring(70,72)).equals("70")) {t7.write(line);t7.newLine();} if ((line.substring(70,72)).equals("80")) {t8.write(line);t8.newLine();} total++; } The problem is that processing starts but after a while I get: java.lang.OutOfMemoryError: no stack trace available I think the problem is the file size, with a small file (21kb), it works fine... but I have to process this big file |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > File processing please help! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|