Wednesday, September 29, 2010

System.out.print, Android

When i strated learning Android, i wanted to know where can i see my debug lines "System.out.print", so i'm sure this will be a easy guideline:

1. Run your application in my case use Netbeans.
2. in commandline execute: adb logcat

That's all, then you'll see i this new window all the messages from System.out.print

Try using android.util.Log instead of System.out.println(), and then use
adb logcat or DDMS to view the results of the logs.

Wednesday, September 15, 2010

Encoding OutputStreams

This is a simple snippet of how to encode a simple output:

OutputStream outStream; // stream to where xml is being sent

BufferedWriter out =
new BufferedWriter(
new OutputStreamWriter(
outStream,
Charset.forName("LATIN1")));

out.write(xmlAsString);
out.flush();

Charsets can easily retrieved as follows:

SortedMap av= Charset.availableCharsets();
for (String cs:av.keySet()) {
System.out.println(cs+", "+Charset.forName(cs).name());
}