1 56 package org.opencrx.base.text.conversion; 57 58 import java.io.FilterWriter ; 59 import java.io.IOException ; 60 import java.io.Writer ; 61 62 65 public class XMLWriter extends FilterWriter { 66 67 public XMLWriter(Writer writer) { 68 super(writer); 69 } 70 71 public void write(char cbuf[], int off, int len) throws IOException { 72 for(int i = off; i < off+len; i++) { 73 this.write(cbuf[i]); 74 } 75 } 76 77 public void write(String s, int off, int len) throws IOException { 78 for(int i = off; i < off+len; i++) { 79 this.write(s.charAt(i)); 80 } 81 } 82 83 public void write(char c) throws IOException { 84 switch(c) { 85 case '<': out.write("<"); break; 86 case '>': out.write(">"); break; 87 case '"': out.write("""); break; 88 case '\'': out.write("'"); break; 89 case '&': out.write("&"); break; 90 default: out.write(c); 91 } 92 } 93 94 } 95 96 | Popular Tags |