
/* input exam.txt: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
output result.txt : 1,6,11 2,7,12 3,8,13 4,9,14 5,10,15
*/
public class Sample {
public static void main(String args[]) throws Exception {
BufferedReader br=new BufferedReader(new FileReader("exam.txt"));
String line=br.readLine();
br.close();
String str="";
if(line!=null) {
String tokens[]=line.split(",");
for(int i=0;i<5;i++) {
int a=1;
int k=i;
for(int j=1;j<=3;j++){
str+=tokens[k];
k=k+5;
if(a<=2)
str+=",";
else
str+=" ";
a++;
}
}
}
BufferedWriter bw=new BufferedWriter(new FileWriter("result.txt"));
bw.write(str);
bw.close();
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.