import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; import java.io.UnsupportedEncodingException; public class symbolRemover { public static void main(String[] args) { if (args.length == 1) { String name[] = (args[0].split("\\.")); try { File outFile = new File(name[0] + "Mod." + name[1]); boolean success = outFile.createNewFile(); if (!success) { System.err.println("File already exist!"); System.err.println("Operation aborted.."); return; } FileOutputStream out = new FileOutputStream(name[0] + "Mod." + name[1]); PrintStream p = new PrintStream(out); FileInputStream fstream = new FileInputStream(args[0]); DataInputStream in = new DataInputStream(fstream); byte tempChar='\0'; byte tempChar1='\0'; byte tempChar2='\0'; byte tempChar3='\0'; if(in.available() != 0) { tempChar = in.readByte(); } while (in.available() != 0) { tempChar3 = tempChar2; tempChar2 = tempChar1; tempChar1 = tempChar; tempChar = in.readByte(); if ((tempChar2 == '>')&&(tempChar3 == ' ')){ continue; } else if ((tempChar2 == ' ')&&(tempChar3 == '>')) continue; else if ((tempChar == '>')&&(tempChar1 == '\n')&&(tempChar2 == '\r')&&(tempChar3 == '>')){ tempChar = '\0'; tempChar1 = '\0'; tempChar2 = '\0'; tempChar3 = '\0'; p.write('\r'); p.write('\n'); p.write('\r'); p.write('\n'); continue; } else if ((tempChar1 == '>')&&(tempChar2 == '\n')&&(tempChar3 == '\r')){ tempChar1 = '\0'; tempChar2 = '\0'; tempChar3 = '\0'; p.write(' '); continue; } else if ((tempChar != '>')&&(tempChar1 == '\n')&&(tempChar2 == '\r')&&(tempChar3 != '>')){ p.write(tempChar3); p.write(' '); p.write(tempChar); tempChar = '\0'; tempChar1 = '\0'; tempChar2 = '\0'; tempChar3 = '\0'; continue; } else if (tempChar3 != '>' && tempChar3 != '\0'){ p.write(tempChar3); } } if (tempChar2 != '>' && tempChar2 != '\0') p.write(tempChar2); if (tempChar1 != '>' && tempChar1 != '\0') p.write(tempChar1); if (tempChar != '>' && tempChar != '\0') p.write(tempChar); in.close(); p.close(); System.out.println("Completed!"); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else System.out.println("Invalid parameters"); } }