Publicado por: lezz | abril 14, 2008

java + sprintf = PrintfFormat

After looking how to do a simple sprintf (I was trying to convert an array of bytes to a string) I found a java class that implements something like the sprintf function that every C programmer knows.

Well, here is the link: http://java.sun.com/developer/technicalArticles/Programming/sprintf
And a snippet of code:

if (buffer[i+8] == saturno_balanca_liberada) {
String x = new String();
for (int k=i+1; k<(i+7);k++){
x += new PrintfFormat("%d").sprintf(buffer[k]);
}
// System.out.println("v->[" + x + "]");
pesoEstavel = x; //pega o peso estavel e balanca bloqueada
proto_ok=1;
break; // para a execucao uma vez que ja pegou o peso estavel
}


Deixe um comentário

Categorias