import java.io.*;
import java.util.Arrays;
import java.util.List;

import org.apache.commons.io.FileUtils;

/**
 * @author Loris NORSIC
 * This plugin enables to convert a .rtf file in .txt file 
 * 
 *
 */
public class Rtf implements Corpoplugins{
    private File fileEntree;
    private File fileSortie;

    private String REGEX = Messages.getString("rtf.0");// //$NON-NLS-1$
    private String REGEX2 = Messages.getString("rtf.1"); //$NON-NLS-1$
    private String REGEX3 = Messages.getString("rtf.2"); //$NON-NLS-1$
    private String REGEX4 = Messages.getString("rtf.3"); //$NON-NLS-1$
    private String REGEX5 = Messages.getString("rtf.4"); //$NON-NLS-1$
    private String REGEX6 = Messages.getString("rtf.5"); //$NON-NLS-1$
    private String REPLACE = Messages.getString("rtf.6"); //$NON-NLS-1$
    private String REPLACE2 = Messages.getString("rtf.7"); //$NON-NLS-1$
    private String REPLACE3 = Messages.getString("rtf.8"); //$NON-NLS-1$

    public Rtf(String in, String out) {
        this.fileEntree = new File(in);
        this.fileSortie = new File(out);
    }
    
    public void Load(File file_in, File file_out){
    	
    }
    
    public void processExtraction(String[] options) throws IOException{
    	
    }
    
    void setFileIn(File file_in){
    	
    }

    void setFileOut(File file_out){
    	
    }
    
    //replace line by line with the regular expression
    public void test() throws IOException {
    	
    	String airlines = FileUtils.readFileToString(fileEntree); //File is transformed in String
    	String text = airlines.replaceAll(this.REGEX, this.REPLACE2); //head of file is delete
    	String tab[] = text.split(Messages.getString("rtf.9")); //$NON-NLS-1$
    	
    	
    	FileUtils.deleteQuietly(fileSortie);//Delete the file with the same name
        for (int i = 0; i < tab.length; i++) { //REGEX used for each line of String tab[]
            String newline = tab[i].replaceAll(this.REGEX2, this.REPLACE);
            newline = newline.replaceAll(this.REGEX3, this.REPLACE2);
            newline = newline.replaceAll(this.REGEX4, this.REPLACE2);
            newline = newline.replaceAll(this.REGEX5, this.REPLACE3);
            newline = newline.replaceAll(this.REGEX6, this.REPLACE3);
            tab[i] = newline;
            FileUtils.write(fileSortie, tab[i], true);
        }
    }


    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        rtf test = new rtf(Messages.getString("rtf.10"), Messages.getString("rtf.11")); //$NON-NLS-1$ //$NON-NLS-2$
        test.test();
    }
}

@@ -58,16 +58,136 @@
 il.List;
+%0Aimport net.xeoh.plugins.base.annotations.PluginImplementation;%0Aimport plugins.Corpoplugins;%0Aimport plugins.Pluginspecs;
 %0A%0Aimport
@@ -320,16 +320,245 @@
 %0A *%0A */%0A
+ @Pluginspecs(%0A        name = %22Rtf%22,%0A        version = %221.0.0%22,%0A        description = %22Extracts text from .rtf Files%22,%0A        author = %22Loris Norsic%22,%0A        dependencies = %22%22,%0A        extensions = %22rtf%22)%0A@PluginImplementation%0A
 public c
@@ -591,16 +591,58 @@
 lugins%7B%0A
+    protected static int BUF_SIZE = 4096;%0A
     priv
@@ -650,26 +650,18 @@
 te File 
-fileEntree
+in
 ;%0A    pr
@@ -671,26 +671,19 @@
 te File 
-fileSortie
+out
 ;%0A%0A    p
@@ -1325,136 +1325,8 @@
 S-1$
-%0A%0A    public Rtf(String in, String out) %7B%0A        this.fileEntree = new File(in);%0A        this.fileSortie = new File(out);%0A    %7D
 %0A   
@@ -1386,119 +1386,17 @@
     
-%09%0A
     
-%7D%0A    %0A    public void processExtraction(String%5B%5D options) throws IOException%7B%0A    %09%0A    %7D%0A    %0A    void 
+this.
 setF
@@ -1405,21 +1405,16 @@
 eIn(
-File 
 file_in)
 %7B%0A  
@@ -1413,32 +1413,23 @@
 _in)
-%7B
+;
 %0A    
-%09%0A
     
-%7D%0A%0A    void 
+this.
 setF
@@ -1435,21 +1435,16 @@
 FileOut(
-File 
 file_out
@@ -1444,23 +1444,17 @@
 ile_out)
-%7B%0A    %09
+;
 %0A    %7D%0A 
@@ -1465,80 +1465,54 @@
     
-//replace line by line with the regular expression%0A    public void test(
+public void processExtraction(String%5B%5D options
 ) th
@@ -1531,16 +1531,20 @@
 tion
- 
 %7B%0A    %09
+    %09
 %0A   
@@ -1594,18 +1594,10 @@
 ing(
-fileEntree
+in
 ); /
@@ -1835,26 +1835,19 @@
 Quietly(
-fileSortie
+out
 );//Dele
@@ -2384,18 +2384,11 @@
 ite(
-fileSortie
+out
 , ta
@@ -2420,252 +2420,138 @@
   %7D%0A
-%0A%0A
     
-public static void main(String%5B%5D args) throws IOException %7B%0A        // TODO Auto-generated method stub
+%0A    void setFileIn(File file_in)%7B%0A    %09this.in = file_in;
 %0A    
+%7D%0A%0A
     
-rtf test = new rtf(Messages.getString(%22rtf.10%22), Messages.getString(%22rtf.11%22)); //$NON-NLS-1$ //$NON-NLS-2$%0A        test.test()
+void setFileOut(File file_out)%7B%0A    %09this.out = file_out
 ;%0A  

Update Rtf.java