当前位置: 首页 > news >正文

0基础学习网站建设企业网站有哪些内容

0基础学习网站建设,企业网站有哪些内容,自己的品牌怎么推广加盟,wordpress log文件大小介绍 Netty的ByteBuf数据位置索引是0开始的。 可以用ByteBuf的getByte(int index)方法从指定位置读出一字节#xff0c;这个操作不会改变ByteBuf的readerIndex 或者 writerIndex 的位置。如果index小于0#xff0c;或者index 1大于ByteBuf的容量#xff0c;就会抛出IndexO…介绍 Netty的ByteBuf数据位置索引是0开始的。 可以用ByteBuf的getByte(int index)方法从指定位置读出一字节这个操作不会改变ByteBuf的readerIndex 或者 writerIndex 的位置。如果index小于0或者index 1大于ByteBuf的容量就会抛出IndexOutOfBoundsException异常。 可以用ByteBuf的readByte()方法从当前readerIndex 读出一字节并且将readerIndex 的值增加1。如果ByteBuf的readableBytes的值小于1就会抛出IndexOutOfBoundsException异常。 可以使用ByteBuf的isReadable()方法判断是否有可读的数据。当(this.writerIndex - this.readerIndex) 的值大于0isReadable()返回true。 writeShort(int value)函数在ByteBuf的当前writerIndex位置开始写入一个16位的整数并且将writerIndex增加2。因为输入参数是int型占4个字节高位的16位被丢弃。 getShort(int index)函数从ByteBuf的绝对位置index开始读取1个16位的整数。这个方法不改变ByteBuf的readerIndex 和 writerIndex。 代码举例 用getByte(int index)方法正常读取数据 代码 package com.thb;import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled;public class Test {public static void main(String[] args) { ByteBuf buf Unpooled.buffer(1); for (int i 0; i 1; i) {buf.writeByte(0x68);}for (int i 0; i buf.capacity(); i) {System.out.println(buf.getByte(i));}}}运行输出 用getByte(int index)方法不正常读取数据抛出异常 代码 package com.thb;import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled;public class Test {public static void main(String[] args) { ByteBuf buf Unpooled.buffer(1); for (int i 0; i 1; i) {buf.writeByte(0x68);}for (int i 0; i buf.capacity() 1; i) {System.out.println(buf.getByte(i));}}}运行输出 用readByte()方法正常读取数据–用readableBytes()判断可读的数据字节数 代码 package com.thb;import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled;public class Test {public static void main(String[] args) { ByteBuf buf Unpooled.buffer(2); for (int i 0; i 2; i) {buf.writeByte(0x68);} while (buf.readableBytes() 0) {System.out.println(buf.readByte());}}}运行输出 用readByte()方法正常读取数据–用isReadable()判断是否有可读的数据 代码 package com.thb;import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled;public class Test {public static void main(String[] args) { ByteBuf buf Unpooled.buffer(2); for (int i 0; i 2; i) {buf.writeByte(0x68);} while (buf.isReadable()) {System.out.println(buf.readByte());}}}运行输出 用getBytes(int index, byte[] dst)读取部分内容到数组中 getBytes(int index, byte[] dst)表示从ByteBuf的绝对位置index开始拷贝部分内容到目的字节数组中。这个操作不改变ByteBuf的readerIndex 和 writerIndex。 package com.thb;import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled;public class Test {public static void main(String[] args) { ByteBuf buf Unpooled.buffer(4);for (int i 0; i buf.capacity(); i) {buf.writeByte(0x68);}byte[] data new byte[2];// 从buf的第二个字节开始拷贝2个字节的内容到data数组中buf.getBytes(1, data);System.out.println(数组data的内容);for (int i 0; i data.length; i) {System.out.println(data[i]);}System.out.println(buf的内容);for (int i 0; i buf.capacity(); i) {System.out.println(buf.getByte(i));}}}运行结果 用writeShort(int value)写入一个short型整数用getShort(int index)读取一个short型整数 package com.thb;import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled;public class Test {public static void main(String[] args) { ByteBuf buf Unpooled.buffer(4);buf.writeShort(2048);// 从buf中读取一个short型整数并打印出来看是否和传入的相同System.out.println(从ByteBuf中读取的short型整数为 buf.getShort(0));}}运行结果
http://www.w-s-a.com/news/442141/

相关文章:

  • 网站图片设计制作制作一个门户网站需要多少钱
  • 虚拟币交易网站源码自己给网站做支付接口
  • 免费的seo网站在线 crm
  • 绍兴市高速公路建设指挥部网站网站主页和子页风格如何统一
  • 获取网站状态网站租金可以做办公费吗
  • 网站开发执行什么标准号wordpress主题 表白
  • 杭州网站推广与优化凡科网是免费的吗
  • 公司网站的重要性门户网站推广介绍方案
  • 做金融网站看那些素材江门网红打卡景点蓬江区
  • 饮食网站模板建网站中企动力优
  • 郑州 制造 网站东平企业建站公司
  • 天津设计师网站大全展示型网站搭建
  • 南宁网站建设 传导网站开发平台开发公司
  • 网站建设好处上海建设工程网站
  • 黑河哈尔滨网站建设太原网站制作定制开发
  • 建站做网站香河住房与建设局网站
  • 如何制造一个网站域名分类网站
  • 解析视频的网站怎么做凡科网快图
  • 企业网站优化问题接单app平台有哪些
  • 怎么做网站后缀识别符号才不会变什么是电子商务网站建设
  • 中山 五金 骏域网站建设专家专门用来制作网页的软件是什么
  • 怎么做刷东西的网站数据分析软件工具有哪些
  • 官方购物网站正品交易网站域名
  • lol网站建设seo 网站太小
  • 网站建设销售职责手机网站制作软件
  • 福州百度企业网站seo如何在电脑上登录wordpress
  • 开发区全力做好网站建设网络广告营销成功案例
  • 114网站建设高并发系统架构
  • php网站打开一片空白wordpress中文广告插件下载
  • 怎样建自己的网站免费的百度关键词排名点击