Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within I/O and Streams
Search Coderanch
Advance search
Google search
Register / Login
Forums
Register
Login
Java
»
I/O and Streams
Concating byte arrays generates NullPointerException
john price
,
Ranch Hand
Sep 16, 2011 22:35:32
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
For some reason, line 3 of the below code generates an error. Why? How many I fix it?
Thanks,
John Price
byte[] concat(byte[] byteSong, byte[] byteMessage) { try { byte[] C = new byte[byteSong.length + byteMessage.length]; System.arraycopy(byteSong, 0, C, 0, byteSong.length); System.arraycopy(byteMessage, 0, C, byteSong.length, byteMessage.length); } catch (Exception eaf) {eaf.printStackTrace();} return C; }
EDIT - Here is the error output :
java.lang.NullPointerException at FileHostingClient.concat(FileHostingClient.java:243) //Line 3 in code above at FileHostingClient$IncomingReader.run(FileHostingClient.java:106) //Line in code that calls Concat at java.lang.Thread.run(Unknown Source)
Rob Spoor
,
Sheriff
staff
Sep 17, 2011 14:40:55
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Obviously either byteSong or byteMessage is null.
Post by:
autobot
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
This thread has been viewed 753 times.
Similar Threads
Writing data to a byte array.
concat 2 strings using constructor
operator question
Data loss converting StringBuilder to byte[]?
(B&S) Help with my Update()
More...
All times above are in ranch (not your local) time.
The current ranch time is
Mar 30, 2024 01:22:10
.