久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <legend id='NR1i2'><style id='NR1i2'><dir id='NR1i2'><q id='NR1i2'></q></dir></style></legend>

      <i id='NR1i2'><tr id='NR1i2'><dt id='NR1i2'><q id='NR1i2'><span id='NR1i2'><b id='NR1i2'><form id='NR1i2'><ins id='NR1i2'></ins><ul id='NR1i2'></ul><sub id='NR1i2'></sub></form><legend id='NR1i2'></legend><bdo id='NR1i2'><pre id='NR1i2'><center id='NR1i2'></center></pre></bdo></b><th id='NR1i2'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='NR1i2'><tfoot id='NR1i2'></tfoot><dl id='NR1i2'><fieldset id='NR1i2'></fieldset></dl></div>
      1. <tfoot id='NR1i2'></tfoot>
      2. <small id='NR1i2'></small><noframes id='NR1i2'>

          <bdo id='NR1i2'></bdo><ul id='NR1i2'></ul>

        將 long 轉(zhuǎn)換為字節(jié)數(shù)組并將其添加到另一個數(shù)組

        Convert long to byte array and add it to another array(將 long 轉(zhuǎn)換為字節(jié)數(shù)組并將其添加到另一個數(shù)組)
            <legend id='gXbTC'><style id='gXbTC'><dir id='gXbTC'><q id='gXbTC'></q></dir></style></legend>
            • <tfoot id='gXbTC'></tfoot>
              • <bdo id='gXbTC'></bdo><ul id='gXbTC'></ul>
                  <tbody id='gXbTC'></tbody>
                <i id='gXbTC'><tr id='gXbTC'><dt id='gXbTC'><q id='gXbTC'><span id='gXbTC'><b id='gXbTC'><form id='gXbTC'><ins id='gXbTC'></ins><ul id='gXbTC'></ul><sub id='gXbTC'></sub></form><legend id='gXbTC'></legend><bdo id='gXbTC'><pre id='gXbTC'><center id='gXbTC'></center></pre></bdo></b><th id='gXbTC'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='gXbTC'><tfoot id='gXbTC'></tfoot><dl id='gXbTC'><fieldset id='gXbTC'></fieldset></dl></div>

                  <small id='gXbTC'></small><noframes id='gXbTC'>

                  本文介紹了將 long 轉(zhuǎn)換為字節(jié)數(shù)組并將其添加到另一個數(shù)組的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我想更改字節(jié)數(shù)組中的值以將長時間戳值放入 M??SB.有人可以告訴我最好的方法是什么.我不想逐位插入值,我認為這是非常低效的.

                  I want to change a values in byte array to put a long timestamp value in in the MSBs. Can someone tell me whats the best way to do it. I do not want to insert values bit-by-bit which I believe is very inefficient.

                  long time = System.currentTimeMillis();
                  Long timeStamp = new Long(time);
                  byte[] bArray = new byte[128];
                  

                  我想要的是這樣的:

                  byte[0-63] = timeStamp.byteValue(); 
                  

                  這樣的事情可能嗎.在此字節(jié)數(shù)組中編輯/插入值的最佳方法是什么.因為 byte 是一個原語,我不認為有一些我可以使用的直接實現(xiàn)?

                  Is something like this possible . What is the best way to edit/insert values in this byte array. since byte is a primitive I dont think there are some direct implementations I can make use of?


                  System.currentTimeMillis() 似乎比Calendar.getTimeInMillis() 快,所以將上面的代碼替換為它.如有錯誤請指正.


                  It seems that System.currentTimeMillis() is faster than Calendar.getTimeInMillis(), so replacing the above code by it.Please correct me if wrong.

                  推薦答案

                  有多種方法:

                  • 使用 ByteBuffer(最佳選擇 - 簡潔易讀):

                  • Use a ByteBuffer (best option - concise and easy to read):

                  byte[] bytes = ByteBuffer.allocate(Long.SIZE / Byte.SIZE).putLong(someLong).array();
                  

                • 您也可以使用 DataOutputStream(更詳細):

                  ByteArrayOutputStream baos = new ByteArrayOutputStream();
                  DataOutputStream dos = new DataOutputStream(baos);
                  dos.writeLong(someLong);
                  dos.close();
                  byte[] longBytes = baos.toByteArray();
                  

                • 最后,您可以手動執(zhí)行此操作(取自 Hector 代碼中的 LongSerializer)(更難閱讀):

                  byte[] b = new byte[8];
                  for (int i = 0; i < size; ++i) {
                    b[i] = (byte) (l >> (size - i - 1 << 3));
                  }
                  

                • 然后您可以通過一個簡單的循環(huán)將這些字節(jié)附加到現(xiàn)有數(shù)組中:

                  Then you can append these bytes to your existing array by a simple loop:

                  // change this, if you want your long to start from 
                  // a different position in the array
                  int start = 0; 
                  for (int i = 0; i < longBytes.length; i ++) {
                     bytes[start + i] = longBytes[i];
                  }
                  

                  這篇關于將 long 轉(zhuǎn)換為字節(jié)數(shù)組并將其添加到另一個數(shù)組的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  quot;Char cannot be dereferencedquot; error(“Char 不能被取消引用錯誤)
                  Java Switch Statement - Is quot;orquot;/quot;andquot; possible?(Java Switch 語句 - 是“或/“和可能的?)
                  Java Replace Character At Specific Position Of String?(Java替換字符串特定位置的字符?)
                  What is the type of a ternary expression with int and char operands?(具有 int 和 char 操作數(shù)的三元表達式的類型是什么?)
                  Read a text file and store every single character occurrence(讀取文本文件并存儲出現(xiàn)的每個字符)
                  Why do I need to explicitly cast char primitives on byte and short?(為什么我需要在 byte 和 short 上顯式轉(zhuǎn)換 char 原語?)

                        <tbody id='vpVxD'></tbody>

                        1. <legend id='vpVxD'><style id='vpVxD'><dir id='vpVxD'><q id='vpVxD'></q></dir></style></legend>
                          <i id='vpVxD'><tr id='vpVxD'><dt id='vpVxD'><q id='vpVxD'><span id='vpVxD'><b id='vpVxD'><form id='vpVxD'><ins id='vpVxD'></ins><ul id='vpVxD'></ul><sub id='vpVxD'></sub></form><legend id='vpVxD'></legend><bdo id='vpVxD'><pre id='vpVxD'><center id='vpVxD'></center></pre></bdo></b><th id='vpVxD'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='vpVxD'><tfoot id='vpVxD'></tfoot><dl id='vpVxD'><fieldset id='vpVxD'></fieldset></dl></div>
                          • <bdo id='vpVxD'></bdo><ul id='vpVxD'></ul>
                          • <tfoot id='vpVxD'></tfoot>
                          • <small id='vpVxD'></small><noframes id='vpVxD'>

                          • 主站蜘蛛池模板: 亚洲一区二区免费 | 日韩国产精品一区二区三区 | 久久久久国产一区二区三区 | 日韩三级免费网站 | 欧美视频一区二区三区 | 成人网视频 | 成人久久久 | 国产成人在线播放 | 69av网| 亚洲婷婷一区 | 亚洲国产一区视频 | 日韩一二区在线观看 | 成人免费一级视频 | 91麻豆精品国产91久久久久久 | 国产区一区| 99久久99热这里只有精品 | 日韩网站免费观看 | 日韩精品视频在线免费观看 | 亚洲视频在线一区 | 欧产日产国产精品v | 免费性视频| 日韩高清在线观看 | 男女激情网 | 日本福利片 | 国产高清免费 | 免费在线观看一区二区 | 亚洲成av片人久久久 | 国产一级片 | 中文字幕中文字幕 | 日韩欧美三级在线 | 一区二区高清 | 日韩欧美一区在线 | 久久久性色精品国产免费观看 | 久久久黑人 | 正在播放国产精品 | 精品亚洲一区二区 | 亚洲一区二区三区免费视频 | 97天天干| 国产精品一级 | 色婷婷激情综合 | 狠狠狠色丁香婷婷综合久久五月 |