// Converts the contents of a file into a CharSequence // suitable for use by the regex package. public CharSequence fromFile(String filename) throws IOException { FileInputStream fis = new FileInputStream(filename); FileChannel fc = fis.getChannel(); // Create a read-only CharBuffer on the file ByteBuffer bbuf = fc.map(FileChannel.MapMode.READ_ONLY, 0, (int)fc.size()); CharBuffer cbuf = Charset.forName("8859_1").newDecoder().decode(bbuf); return cbuf; }