mark 和 reset

简介: mark 和 reset

mark 是在读取时,做一个标记,即使 position 改变,只要调用 reset 就能回到 mark 的位置

注意

rewind 和 flip 都会清除 mark 位置

字符串与 ByteBuffer 互转

ByteBuffer buffer1 = StandardCharsets.UTF_8.encode("你好"); ByteBuffer buffer2 = Charset.forName("utf-8").encode("你好");

debug(buffer1); debug(buffer2);

CharBuffer buffer3 = StandardCharsets.UTF_8.decode(buffer1); System.out.println(buffer3.getClass()); System.out.println(buffer3.toString());

结果 +-------------------------------------------------+ |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f | +--------+-------------------------------------------------+----------------+ |00000000| e4 bd a0 e5 a5 bd                               |......          | +--------+-------------------------------------------------+----------------+ +-------------------------------------------------+ |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f | +--------+-------------------------------------------------+----------------+ |00000000| e4 bd a0 e5 a5 bd                               |......          | +--------+-------------------------------------------------+----------------+ class java.nio.HeapCharBuffer 你好


目录
打赏
0
0
0
0
0
分享
相关文章
Thread State 详解
前言 文本已收录至我的GitHub仓库,欢迎Star:github.com/bin39232820… 种一棵树最好的时间是十年前,其次是现在
192 0
Control+Break在JVM中的处理
在 Oracle Solaris 或 Linux 操作系统上, 在应用程序控制台 (标准输入) 中按下Ctrl控制键和反斜线 (\) 键的组合会导致 Java 热点 VM 将线程转储打印到应用程序的标准输出。在 Windows 上, 等效的键序列是控件和中断键。这些组合键的一般术语是Control + Break 处理程序。
254 0
大年初一mark一下
新的一年将会下线个人ORACLE外文blog,精力有限,会全力在阿里云云栖社区分享,主要内容还是数据库相关,包括但不限于以下内容: ORACLE数据库性能分析 PostgreSQL数据库全栈支持 PPAS数据库全栈支持 专注ORACLE数据库和应用迁移至阿里云PPAS、PostgreSQL等数据...
1468 0
[20171123]Skip Locked and ITL slot 2.txt
[20171123]Skip Locked and ITL slot 2.txt --//昨天看链接提到Skip Locked and ITL slot相关问题,链接 http://jonathanlewis.
1114 0
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等