I'm adding multiple bytes array from each row, that means I need to append all of them to a variable. But this prints a empty byte array because it can't be changed. What I can do to append more bytes?
ResultSet rs = stmt.executeQuery(query);
int matchesLength = 0;
try {
boolean b = rs.last();
if (b) {
matchesLength = rs.getRow();
}
}
catch (SQLException e) {
e.printStackTrace();
}
byte[] matches = new byte[118 * matchesLength];
while ( rs.next() ) {
String matchId = rs.getString("id");
String matchTitle = rs.getString("title");
String matchDescription = rs.getString("description");
int matchPlayers = rs.getInt("max_players");
int matchMaxPlayers = rs.getInt("max_players");
String matchHostId = rs.getString("host_id");
short matchPlayersShort = (short) matchPlayers;
byte[] matchPlayersBytes = ByteBuffer.allocate(2).putShort(matchPlayersShort).array();
short matchMaxPlayersShort = (short) matchMaxPlayers;
byte[] matchMaxPlayersBytes = ByteBuffer.allocate(2).putShort(matchMaxPlayersShort).array();
byte[][] match = {
String.format("%1$-" + 32 + "s", matchId).getBytes(),
String.format("%1$-" + 22 + "s", matchTitle).getBytes(),
String.format("%1$-" + 44 + "s", matchDescription).getBytes(),
matchPlayersBytes,
matchMaxPlayersBytes,
String.format("%1$-" + 16 + "s", matchHostId).getBytes()
};
// global offset variable, for each array copy
combineBytes(match, matches);
}
combineBytesdo?combineBytestomatches?