Skip to main content

Posts

Showing posts with the label xml

Sleepy Day

Today feels like a sleepy day, I don't know why that is. It just feels that way. I wish I could figure out why life happens the way it does. But I don't understand how anything goes about in this life. If I could understand one thought in life...I think I'd like it to be able to grasp why we are here on this Earth. Is it because the aliens want us to become something better than we are? I mean they're the ones in charge right? I think they are.

Easy Way To Create HTML/XML String

A simple way to create html tags in Java. It won't create a tree that you can parse, but it will create the text needed. You see we'll use the StringBuilder class along with the Formatter class to accomplish this. This provides a simple way to format a string without using String.format inside of a sb.append call. import java.util.Formatter; import java.util.Locale; public class LocalMe { public static void main(String[] args) { StringBuilder sb = new StringBuilder(); Formatter formatter = new Formatter(sb, Locale.ENGLISH); formatter.format("<%s>%s</%s>", "greeting", "Hello World", "greeting"); System.out.println(formatter.toString()); } }