--- /dev/null
+package org.simantics.graph.compiler.internal.resourceFiles;
+
+import java.io.FilterWriter;
+import java.io.IOException;
+import java.io.Writer;
+
+public class FilterCRWriter extends FilterWriter {
+
+ public FilterCRWriter(Writer out) {
+ super(out);
+ }
+
+ @Override
+ public void write(int c) throws IOException {
+ if(c != '\r')
+ out.write(c);
+ }
+
+ @Override
+ public void write(char[] cbuf, int off, int len) throws IOException {
+ int begin = 0;
+ for(int i=0;i<len;++i) {
+ if(cbuf[off+i] == '\r') {
+ if(i > begin)
+ write(cbuf, off+begin, i-begin);
+ begin = i+1;
+ }
+ }
+ if(len > begin)
+ write(cbuf, off+begin, len-begin);
+ }
+
+ @Override
+ public void write(String str, int off, int len) throws IOException {
+ int begin = 0;
+ for(int i=0;i<len;++i) {
+ if(str.charAt(off+i) == '\r') {
+ if(i > begin)
+ write(str, off+begin, i-begin);
+ begin = i+1;
+ }
+ }
+ if(len > begin)
+ write(str, off+begin, len-begin);
+ }
+
+}
import java.io.StringWriter;
import java.io.Writer;
import java.net.URL;
+import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import freemarker.template.Template;
public class ResourceFile implements IResourceFile {
+ private final static Charset UTF8 = Charset.forName("UTF-8");
+
String packageName;
String className;
List<ResourceRef> resources;
@Override
public InputStream getContent() {
StringWriter writer = new StringWriter();
- write(writer);
- return new ByteArrayInputStream(writer.toString().replace("\r\n", "\n").getBytes());
+ write(new FilterCRWriter(writer));
+ return new ByteArrayInputStream(writer.toString().getBytes(UTF8));
}
/* (non-Javadoc)