remove zero from ByteString.fromArray(array()) The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceConvert ByteBuffer to byte array javaHow can I concatenate two arrays in Java?Create ArrayList from arrayIterating through a Collection, avoiding ConcurrentModificationException when removing objects in a loopHow do I call one constructor from another in Java?What's the simplest way to print a Java array?How can I pad an integer with zeros on the left?How to get an enum value from a string value in Java?How do I determine whether an array contains a particular value in Java?How do I declare and initialize an array in Java?Why is it faster to process a sorted array than an unsorted array?

How do spell lists change if the party levels up without taking a long rest?

Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?

How did the audience guess the pentatonic scale in Bobby McFerrin's presentation?

One-dimensional Japanese puzzle

Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?

Can the DM override racial traits?

"is" operation returns false even though two objects have same id

Sort list of array linked objects by keys and values

How to determine omitted units in a publication

How do I design a circuit to convert a 100 mV and 50 Hz sine wave to a square wave?

What aspect of planet Earth must be changed to prevent the industrial revolution?

For what reasons would an animal species NOT cross a *horizontal* land bridge?

The following signatures were invalid: EXPKEYSIG 1397BC53640DB551

Word to describe a time interval

My body leaves; my core can stay

Presidential Pardon

Variable with quotation marks "$()"

Did the new image of black hole confirm the general theory of relativity?

Are spiders unable to hurt humans, especially very small spiders?

Are there continuous functions who are the same in an interval but differ in at least one other point?

Huge performance difference of the command find with and without using %M option to show permissions

What to do when moving next to a bird sanctuary with a loosely-domesticated cat?

Was credit for the black hole image misappropriated?

Mortgage adviser recommends a longer term than necessary combined with overpayments



remove zero from ByteString.fromArray(array())



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceConvert ByteBuffer to byte array javaHow can I concatenate two arrays in Java?Create ArrayList from arrayIterating through a Collection, avoiding ConcurrentModificationException when removing objects in a loopHow do I call one constructor from another in Java?What's the simplest way to print a Java array?How can I pad an integer with zeros on the left?How to get an enum value from a string value in Java?How do I determine whether an array contains a particular value in Java?How do I declare and initialize an array in Java?Why is it faster to process a sorted array than an unsorted array?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am trying to remove zeros from ByteString.fromArray(msgBuf.array()) but I was able to ignore and see the values with out zero by ignoring the bytes logger using ByteString.fromArray(msgBuf.array()).sliceWithKnownBound(0, 91)



But when I return the above with slice the zeros are still at the end of my message



public ByteString marshal(Msg req) 
MsgOff in=new MsgOff(req.getBase());
ByteBuffer msgBuf = ByteBuffer.allocate(128);
msgBuf.put((byte)0x02);//STX
msgBuf.put(in.base.getString(2).getBytes());
msgBuf.put(FS);
msgBuf.put((byte)0x03);
return ByteString.fromArray(msgBuf.array());










share|improve this question
























  • I am pretty sure that array() is returning the whole allocated buffer no matter how much is occupied, that is, 128 bytes in above case. I would only get bb.position() bytes

    – Carlos Heuberger
    Mar 8 at 12:41












  • maybe msgBuf.flip() and stackoverflow.com/a/28744228/85421

    – Carlos Heuberger
    Mar 8 at 12:47

















0















I am trying to remove zeros from ByteString.fromArray(msgBuf.array()) but I was able to ignore and see the values with out zero by ignoring the bytes logger using ByteString.fromArray(msgBuf.array()).sliceWithKnownBound(0, 91)



But when I return the above with slice the zeros are still at the end of my message



public ByteString marshal(Msg req) 
MsgOff in=new MsgOff(req.getBase());
ByteBuffer msgBuf = ByteBuffer.allocate(128);
msgBuf.put((byte)0x02);//STX
msgBuf.put(in.base.getString(2).getBytes());
msgBuf.put(FS);
msgBuf.put((byte)0x03);
return ByteString.fromArray(msgBuf.array());










share|improve this question
























  • I am pretty sure that array() is returning the whole allocated buffer no matter how much is occupied, that is, 128 bytes in above case. I would only get bb.position() bytes

    – Carlos Heuberger
    Mar 8 at 12:41












  • maybe msgBuf.flip() and stackoverflow.com/a/28744228/85421

    – Carlos Heuberger
    Mar 8 at 12:47













0












0








0








I am trying to remove zeros from ByteString.fromArray(msgBuf.array()) but I was able to ignore and see the values with out zero by ignoring the bytes logger using ByteString.fromArray(msgBuf.array()).sliceWithKnownBound(0, 91)



But when I return the above with slice the zeros are still at the end of my message



public ByteString marshal(Msg req) 
MsgOff in=new MsgOff(req.getBase());
ByteBuffer msgBuf = ByteBuffer.allocate(128);
msgBuf.put((byte)0x02);//STX
msgBuf.put(in.base.getString(2).getBytes());
msgBuf.put(FS);
msgBuf.put((byte)0x03);
return ByteString.fromArray(msgBuf.array());










share|improve this question
















I am trying to remove zeros from ByteString.fromArray(msgBuf.array()) but I was able to ignore and see the values with out zero by ignoring the bytes logger using ByteString.fromArray(msgBuf.array()).sliceWithKnownBound(0, 91)



But when I return the above with slice the zeros are still at the end of my message



public ByteString marshal(Msg req) 
MsgOff in=new MsgOff(req.getBase());
ByteBuffer msgBuf = ByteBuffer.allocate(128);
msgBuf.put((byte)0x02);//STX
msgBuf.put(in.base.getString(2).getBytes());
msgBuf.put(FS);
msgBuf.put((byte)0x03);
return ByteString.fromArray(msgBuf.array());







java akka






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 16:23









Abinash Ghosh

403215




403215










asked Mar 8 at 12:24









PlasteredPlastered

36




36












  • I am pretty sure that array() is returning the whole allocated buffer no matter how much is occupied, that is, 128 bytes in above case. I would only get bb.position() bytes

    – Carlos Heuberger
    Mar 8 at 12:41












  • maybe msgBuf.flip() and stackoverflow.com/a/28744228/85421

    – Carlos Heuberger
    Mar 8 at 12:47

















  • I am pretty sure that array() is returning the whole allocated buffer no matter how much is occupied, that is, 128 bytes in above case. I would only get bb.position() bytes

    – Carlos Heuberger
    Mar 8 at 12:41












  • maybe msgBuf.flip() and stackoverflow.com/a/28744228/85421

    – Carlos Heuberger
    Mar 8 at 12:47
















I am pretty sure that array() is returning the whole allocated buffer no matter how much is occupied, that is, 128 bytes in above case. I would only get bb.position() bytes

– Carlos Heuberger
Mar 8 at 12:41






I am pretty sure that array() is returning the whole allocated buffer no matter how much is occupied, that is, 128 bytes in above case. I would only get bb.position() bytes

– Carlos Heuberger
Mar 8 at 12:41














maybe msgBuf.flip() and stackoverflow.com/a/28744228/85421

– Carlos Heuberger
Mar 8 at 12:47





maybe msgBuf.flip() and stackoverflow.com/a/28744228/85421

– Carlos Heuberger
Mar 8 at 12:47












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55063183%2fremove-zero-from-bytestring-fromarrayarray%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55063183%2fremove-zero-from-bytestring-fromarrayarray%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

1928 у кіно

Захаров Федір Захарович

Ель Греко