Warning: fsockopen(): unable to connect to localhost:5581 (Connection refused) in /var/www/fang/wiki/extensions/JavaCoder/JavaCoder_body.php on line 690 Warning: fsockopen(): unable to connect to localhost:5581 (Connection refused) in /var/www/fang/wiki/extensions/JavaCoder/JavaCoder_body.php on line 696 Warning: fwrite() expects parameter 1 to be resource, boolean given in /var/www/fang/wiki/extensions/JavaCoder/JavaCoder_body.php on line 700 Warning: fread() expects parameter 1 to be resource, boolean given in /var/www/fang/wiki/extensions/JavaCoder/JavaCoder_body.php on line 701 FA/FileTransformer - ggc

FA/FileTransformer

From ggc

Jump to: navigation, search

01 package FA;
02 
03 
04 /**
05  * This program will read a line of string data from one file and a pairs of strings from
06  * a second file. The pairs of strings contain a target and replacement. Each example
07  * of  a string target is replaced by the corresponding string, replacement.
08  @author Frank Anderson
09  */
10 public class FileTransformer
11 {
12   public FileTransformer()
13   {
14     String sourceFile;
15     String originalText;
16     ArrayList<String> replacements;
17     System.out.println("Hello JavaWIDE!");
18     /** Read text from the sourceFile and store into originalText.  */
19     public void setSourceFile(String fileForText)
20     {
21       sourceFile=fileForText;
22       Scanner scannerSource=new Scanner(sourceFile);
23       originalText=scannerSource.next();
24     }
25     /** Takes a single string form a file and read the data into an ArrayList.*/
26 
27     public void addReplacements(String fileForReplacements)
28     {
29       Scanner scannerReplacements = new Scanner(fileForReplacements);
30       while(scannerReplacements.hasNext())
31         replacements.addNext();
32     }
33 
34     /**Converts the originalText using replacements and returns the result as a string.*/
35     public String getTransformedText(String original, String frist, String replaceWith)
36     {
37       String string2="";
38       string2=originalText;
39       for(Replacer single; replacements)
40       {
41         Replacer model=new Replacer(single);
42         string2=model.getReplaced(string2);
43       }
44       System.out.println(string2);
45     }
46 
47 
48   }
49 }


Download/View FA/FileTransformer.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter