Win a copy of Head First Android this week in the Android forum!

Uwe Pfeifer

Greenhorn
+ Follow
since Jan 31, 2014
Uwe likes ...
IntelliJ IDE Chrome Windows
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Uwe Pfeifer

nm I got it now. The cursor2 is 5 at the beginning and the data is starting at position 6. first part is type and sessionID. that gets passed.
6 years ago
can someone explain me, why here:



the startPosition isn't in the first run 1 too high? like it usually starts at 0 and now before the 1st loop the cursor is incremented by 1 and so doesnt read the first byte probably? Or am I wrong?
6 years ago
ok, in future I'll write such questions into the other forum. Thank you
6 years ago
I've solved this using a readByte method:



And this method is executed here like this:



But this code is used from somewhere else. I'll try to recode this if I fully understand it.
6 years ago

Henry Wong wrote:
Oops, looks like I misread your request -- I thought you had an array of strings.

Anyway, almost the same response. You need a loop, where each iteration of the loop will scan to get two strings, and whose exit condition is when those two strings are blank. So, I guess you were right -- you need an outer loop and an inner loop (perhaps even two inner loops).

Henry



Ok thank you. It doesn't look like you have any example code. I'll continue trying.
6 years ago
The data looks like this:

hostname\0A Minecraft Server\0gametype\0SMP\0 ... hostip\0127.0.0.1\0\0
6 years ago
I have to read until there are 2 times \0 in the array for the first part.
6 years ago

Henry Wong wrote:
How about a single "for" loop, where the index is incremented by two in each iteration? And where the key is at the index, and the value is at the index + 1?
Henry



Do you have any example code? I tried to code it but I just can't. I need an example.

6 years ago
Hi all. I have a byte array. I now want to split the entries into HashMap<String,String> key/value pairs. How do I best do this?
Here is how a response looks from the server, so how the byte array looks: http://wiki.vg/Query#Response_3

Here is the code I have so far:



I think it's done using 2 for loops but I don't get how to. Can anyone give me any example?
The response is in two parts. (the byte array) The first part is a list of null-terminated strings, representing (key1, value1, key2, value2 ...).
And I now want to get these key1, value2... from the byte array, answer3 i received.
6 years ago
ok thank you - they even used Java5 I think it's from 2004.
6 years ago
Hi. I bought Heads First Design Patterns 1st edition a few days back. Now I found out theres a 2nd edition for Java 8. My question is, is it ok if I use the older book because my printer is dead and I can't print out this "send back" thing. I mean it's no cheap book so ... I hope the changes are not too many in the book ... I got a book New in Java 8 (Lambdas & Streams, Date/Time API and Java FX). Also some more changes are listed. Is that book enough and I don't neccessarily need the 2nd edition of Heads First Design Patterns? Thanks!
6 years ago
ok thank you very much for your help, I'll have a look into all that ;D
7 years ago
maybe i should ask again in the beginning java forum?
7 years ago
How do I get insets? And what is to clip the graphics object? I don't really get this. And with draw on g2 do you mean i should do: g2.drawImage(image,0,0,this);?
Sorry, I'm totally new to this.
7 years ago
I already tried:

newImage = image.getScaledInstance(picPanel.getWidth()-10, picPanel.getHeight(), java.awt.Image.SCALE_SMOOTH);

so -10 of the width but then it only shows a border in not the dark gray color of the panel on the rigth side of the panel, or an empty space or what it is.
7 years ago