Ignore:
Timestamp:
05/17/11 15:40:16 (14 years ago)
Author:
sherbold
Message:
  • fixed bug regarding encoding of XML files
Location:
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/LogPreprocessor.java

    r1 r44  
    33import java.io.File; 
    44import java.io.FileNotFoundException; 
     5import java.io.FileOutputStream; 
    56import java.io.FileReader; 
    6 import java.io.FileWriter; 
    77import java.io.IOException; 
     8import java.io.OutputStreamWriter; 
    89 
    910import org.apache.commons.codec.binary.Base64; 
     
    2829         
    2930        public void convertToXml(String source, String target) throws IOException, FileNotFoundException { 
    30                 FileWriter targetFile = new FileWriter(target); 
    31                 targetFile.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + StringTools.ENDLINE); 
     31                OutputStreamWriter targetFile = new OutputStreamWriter(new FileOutputStream(target), "UTF-16"); 
     32                targetFile.write("<?xml version=\"1.0\" encoding=\"UTF-16\"?>" + StringTools.ENDLINE); 
    3233                targetFile.write("<log>" + StringTools.ENDLINE); 
    3334                processFile(source, targetFile); 
     
    4142         
    4243        public void convertDirToXml(String path, String target) throws IOException, FileNotFoundException { 
    43                 FileWriter targetFile = new FileWriter(target); 
    44                 targetFile.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + StringTools.ENDLINE); 
     44                OutputStreamWriter targetFile = new OutputStreamWriter(new FileOutputStream(target), "UTF-16"); 
     45                targetFile.write("<?xml version=\"1.0\" encoding=\"UTF-16\"?>" + StringTools.ENDLINE); 
    4546                targetFile.write("<log>" + StringTools.ENDLINE); 
    4647                File folder = new File(path); 
     
    6263        } 
    6364 
    64         private void processFile(String source, FileWriter targetFile) 
     65        private void processFile(String source, OutputStreamWriter targetFile) 
    6566                        throws FileNotFoundException, IOException { 
    6667                File f = new File(source); 
  • trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/ReplayGenerator.java

    r1 r44  
    22 
    33import java.io.File; 
    4 import java.io.FileWriter; 
     4import java.io.FileOutputStream; 
    55import java.io.IOException; 
     6import java.io.OutputStreamWriter; 
    67import java.util.List; 
    78 
     
    1415                 
    1516        public void createLogfileMultipleSessions(List<List<ReplayableEvent<?>>> sequences, String filename) { 
    16                 FileWriter writer = openReplayFile(filename); 
     17                OutputStreamWriter writer = openReplayFile(filename); 
    1718                if( writer!=null ) {             
    1819                        try { 
    19                                 writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + StringTools.ENDLINE); 
     20                                writer.write("<?xml version=\"1.0\" encoding=\"UTF-16\"?>" + StringTools.ENDLINE); 
    2021                                writer.write("<log>" + StringTools.ENDLINE); 
    2122 
     
    3334         
    3435        public void createLogfileSingleSession(List<ReplayableEvent<?>> actions, String filename) { 
    35                 FileWriter writer = openReplayFile(filename); 
     36                OutputStreamWriter writer = openReplayFile(filename); 
    3637                if( writer!=null ) {             
    3738                        try { 
    38                                 writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + StringTools.ENDLINE); 
     39                                writer.write("<?xml version=\"1.0\" encoding=\"UTF-16\"?>" + StringTools.ENDLINE); 
    3940                                writer.write("<log>" + StringTools.ENDLINE); 
    4041         
     
    4950        } 
    5051 
    51         private FileWriter openReplayFile(String filename) { 
     52        private OutputStreamWriter openReplayFile(String filename) { 
    5253                File file = new File(filename); 
    5354                boolean fileCreated; 
     
    6364                        Console.printStacktrace(e); 
    6465                } 
    65                 FileWriter writer = null; 
     66                OutputStreamWriter writer = null; 
    6667                try { 
    67                         writer = new FileWriter(file); 
     68                        writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-16"); 
    6869                } catch (IOException e) { 
    6970                        Console.printerrln("Unable to open file for writing (read-only file):" + filename); 
     
    7374        } 
    7475         
    75         private void writeSession(List<ReplayableEvent<?>> actions, FileWriter writer) 
     76        private void writeSession(List<ReplayableEvent<?>> actions, OutputStreamWriter writer) 
    7677                        throws IOException { 
    7778                writer.write(" <session>" + StringTools.ENDLINE); 
Note: See TracChangeset for help on using the changeset viewer.