
API in Java
103
for (byte c : command.getBytes("US-ASCII")) {
ret[i++] = c;
}
} else {
String[] str = command.split("\n");
int i = 1;
int[] iTmp = new int[str.length];
for (int a = 0; a < str.length; a++) {
iTmp[a] = writeLen(str[a]).length + str[a].length();
}
for (int b : iTmp) {
i += b;
}
ret = new byte[i];
int counter = 0;
for (int a = 0; a < str.length; a++) {
int j = 0;
byte[] b = writeLen(str[a]);
for (j = 0; j < b.length; j++) {
ret[counter++] = b[j];
}
for (byte c : str[a].getBytes("US-ASCII")) {
ret[counter++] = c;
}
}
}
out.write(ret);
return "Sent successfully";
} catch (IOException ex) {
Logger.getLogger(WriteCommand.class.getName()).log(Level.SEVERE, null, ex);
return "failed";
}
}
}
References
[1] http:/ / www. mikrotik. com/ download/ libAPI. jar
Komentáře k této Příručce