code cleanup / jdoc
[nikiroo-utils.git] / src / be / nikiroo / fanfix / library / Template.java
index e247e27962e6fe6d94d0a913a3a2afcadaa5c0dd..3536d5f12efccf7da066ce4b1d140553c633e631 100644 (file)
@@ -1,6 +1,5 @@
 package be.nikiroo.fanfix.library;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.HashMap;
@@ -8,7 +7,6 @@ import java.util.List;
 import java.util.Map;
 
 import be.nikiroo.utils.IOUtils;
-import be.nikiroo.utils.StringUtils;
 import be.nikiroo.utils.streams.ReplaceInputStream;
 
 public class Template {
@@ -60,26 +58,15 @@ public class Template {
                                        valueOne.close();
                                }
                        }
+
                        from[i] = "${" + key + "}";
                        to[i] = value.toString();
 
                        i++;
                }
-
-               InputStream in = IOUtils.openResource(location, name);
                
-               //TODO: pending fix in replace stream
-               String data = IOUtils.readSmallStream(in);
-               in.close();
-               for(i = 0 ; i < from.length;i++) {
-                       data=data.replace(from[i], to[i]);
-               }
-               
-               //in = new ReplaceInputStream(in, from, to);
-               in = new ByteArrayInputStream(StringUtils.getBytes(data));
-               // END TODO
-               
-               return in;
+               InputStream in = IOUtils.openResource(location, name);
+               return new ReplaceInputStream(in, from, to);
        }
 
        public synchronized Template set(String key, String value) {