日期:2014-05-20  浏览次数:20669 次

IO的问题
FileChannel   fc   =new
FileOutputStream( "data.txt ").getChannel();
        fc.write(ByteBuffer.wrap( "Some   text ".getBytes()));
        fc.close();
fc   =   new   FileInputStream( "data.txt ").getChannel();
        ByteBuffer   buff   =   ByteBuffer.allocate(BSIZE);
        fc.read(buff);
        buff.flip();
        //   Doesn 't   work:
        //System.out.println(buff.asCharBuffer());
        //   Decode   using   this   system 's   default   Charset:
        buff.rewind();
        String   encoding   =   System.getProperty( "file.encoding ");//这里的//getProperty后面的属性是怎么回事?是怎么得知这个属性的?
        System.out.println( "Decoded   using   "   +   encoding   +   ":   "  
            +   Charset.forName(encoding).decode(buff));//还有请解释这一排//的内容

------解决方案--------------------
up