1 28 29 package com.caucho.vfs; 30 31 import java.io.IOException ; 32 import java.io.InputStream ; 33 import java.io.Reader ; 34 35 class Utf16RevReader extends Reader { 36 private InputStream is; 37 38 41 Utf16RevReader(InputStream is) 42 { 43 this.is = is; 44 } 45 46 49 public int read() 50 throws IOException 51 { 52 int ch1 = is.read(); 53 int ch2 = is.read(); 54 55 if (ch2 < 0) 56 return -1; 57 58 return (ch2 << 8) + ch1; 59 } 60 61 64 public int read(char []cbuf, int off, int len) 65 throws IOException 66 { 67 int i = 0; 68 69 for (i = 0; i < len; i++) { 70 int ch1 = is.read(); 71 int ch2 = is.read(); 72 73 if (ch1 < 0) 74 return i == 0 ? -1 : i; 75 76 cbuf[off + i] = (char) ((ch2 << 8) + ch1); 77 } 78 79 return i; 80 } 81 82 85 public void close() 86 { 87 } 88 } 89 | Popular Tags |