public static void main(String args[]){ BytesWritable cv = new BytesWritable(); String str1 = "1234567"; String str2 = "123450"; cv.set(str1.getBytes(), 0, str1.getBytes().length); System.out.println(new String(cv.getBytes())); cv.set(str2.getBytes(), 0, str2.getBytes().length); System.out.println(new String(cv.getBytes())); }<pre code_snippet_id="340846" snippet_file_name="blog_20140512_1_50663" name="code" class="java">output: 12345671234507</pre><pre code_snippet_id="340846" snippet_file_name="blog_20140512_2_6223415" name="code" class="java"> public static void main(String args[]){ BytesWritable cv = new BytesWritable(); String str1 = "1234567"; String str2 = "123450"; cv.set(str1.getBytes(), 0, str1.getBytes().length); System.out.println(new String(cv.getBytes())); cv.setCapacity(0); cv.set(str2.getBytes(), 0, str2.getBytes().length); System.out.println(new String(cv.getBytes())); } output: 1234567123450</pre><br> <br> <pre></pre> <br>
本欄目更多精彩內容:http://www.bianceng.cnhttp://www.bianceng.cn/webkf/tools/