Package org.apache.abdera.i18n.text.io

Examples of org.apache.abdera.i18n.text.io.PeekAheadInputStream


    }

    @Test
    public void testPeekAheadInputStream() throws Exception {
        ByteArrayInputStream in = new ByteArrayInputStream(new byte[] {0x01, 0x02, 0x03, 0x04});
        PeekAheadInputStream pais = new PeekAheadInputStream(in);
        byte[] peek = new byte[2];
        byte[] read = new byte[2];
        pais.peek(peek);
        pais.read(read);
        assertEquals(read[0], peek[0]);
        assertEquals(read[1], peek[1]);
        byte[] newread = new byte[2];
        assertFalse(read[0] == newread[0]);
        assertFalse(read[1] == newread[1]);
View Full Code Here


public class FOMXmlVersionInputStream extends FilterInputStream {

    private String version = null;

    public FOMXmlVersionInputStream(InputStream in) {
        super(new PeekAheadInputStream(in, 4));
        try {
            version = detectVersion();
        } catch (IOException e) {
        }
    }
View Full Code Here

        return version;
    }

    private String detectVersion() throws IOException {
        String version = "1.0";
        PeekAheadInputStream pin = (PeekAheadInputStream)this.in;
        try {
            byte[] p = new byte[200];
            pin.peek(p);
            XMLStreamReader xmlreader =
                XMLInputFactory.newInstance().createXMLStreamReader(new java.io.ByteArrayInputStream(p));
            String v = xmlreader.getVersion();
            if (v != null)
                version = v;
View Full Code Here

        super(in);
    }

    protected String detectEncoding() throws IOException {
        String charset = super.detectEncoding();
        PeekAheadInputStream pin = getInternal();
        try {
            byte[] p = new byte[200];
            pin.peek(p);
            XMLStreamReader xmlreader =
                XMLInputFactory.newInstance().createXMLStreamReader(new java.io.ByteArrayInputStream(p));
            String cs = xmlreader.getCharacterEncodingScheme();
            if (cs != null)
                charset = cs;
View Full Code Here

  extends FilterInputStream {

  private String version = null;
 
  public FOMXmlVersionInputStream(InputStream in) {
    super(new PeekAheadInputStream(in,4));
    try {
      version = detectVersion();
    } catch (IOException e) {}
  }
View Full Code Here

    return version;
  }
 
  private String detectVersion() throws IOException {
    String version = "1.0";
    PeekAheadInputStream pin = (PeekAheadInputStream) this.in;
    try {
      byte[] p = new byte[200];
      pin.peek(p);
      XMLStreamReader xmlreader =
        XMLInputFactory.newInstance().createXMLStreamReader(
          new java.io.ByteArrayInputStream(p));
      String v = xmlreader.getVersion();
      if (v != null) version = v;
View Full Code Here

    super(in);
  }

  protected String detectEncoding() throws IOException {
    String charset = super.detectEncoding();
    PeekAheadInputStream pin = getInternal();
    try {
      byte[] p = new byte[200];
      pin.peek(p);
      XMLStreamReader xmlreader =
        XMLInputFactory.newInstance().createXMLStreamReader(
          new java.io.ByteArrayInputStream(p));
      String cs = xmlreader.getCharacterEncodingScheme();
      if (cs != null) charset = cs;
View Full Code Here

  }
 
  @Test
  public void testPeekAheadInputStream() throws Exception {
    ByteArrayInputStream in = new ByteArrayInputStream(new byte[] {0x01,0x02,0x03,0x04});
    PeekAheadInputStream pais = new PeekAheadInputStream(in);
    byte[] peek = new byte[2];
    byte[] read = new byte[2];
    pais.peek(peek);
    pais.read(read);
    assertEquals(peek[0],read[0]);
    assertEquals(peek[1],read[1]);
    byte[] newread = new byte[2];
    assertFalse(read[0] == newread[0]);
    assertFalse(read[1] == newread[1]);   
View Full Code Here

TOP

Related Classes of org.apache.abdera.i18n.text.io.PeekAheadInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.