Showing posts from 2008

Java object serialization with Xstream

It's an intresting tool. So I'd like to share some of the facts about it. Xstream is used to convert java objects to xml and vice versa. We need this kind of conversion because object persistance and data transportation can be done very easily with xml. ----------------------------------------------------------------------------------------- Object -> XML by Using Xstream libs you can directly convert any object to xml doc. String xml = xstream.toXML( Object o ); ---------------------------------------------------------------- XML -> Object XStream xs = new XStream(new DomDriver()); FileInputStream fis; ObjectInputStream in = null; fis = new FileInputStream("Path to the xml file"); xs.alias("person", Person.class); // give alias given to Person.class try { in = xs.createObjectInputStream(fis); // Convert happens here } catch (IOException e) { e.printStackTrace();

Thousend seperator function - (1,00,000)

Normally if we write a number that is more than 1000, we normally write it with thousend seperator commas other than write it at once. Eg : If we want to write 203465397465 we write it as number : 203,465,397,465 this way we can read the number more easily than other way. So after adding commas to that number the number no longer be a in number format. We cant add, divide, substract.....etc. public String convertThousendsWithCommas(String num) { String pattern = "#,###.##;-#,###.##"; //pattern that we want double value = 0.0; String out = null; try { value = Double.parseDouble(num); NumberFormat nf = NumberFormat.getInstance(); if (nf instanceof DecimalFormat) { DecimalFormat df = (DecimalFormat) nf; df.applyPattern(pattern); out = df.format(value); } } catch (NumberFormatException n){ System.out.print("not a number:

Firefox Mobile Concept Video

Firefox Mobile Concept Video Firefox is coming to mobile. The innovation, usability, and extensibility that has propelled Firefox to 200 million users is set to do the same for Firefox in a mobile setting. User experience is the most important aspect of having a compelling mobile product. Every bit of interaction and pixel of presentation counts when typing is laborious and screen sizes are minuscule. Many of the standard interaction models, like menus, always-present chrome, and having a cursor, don’t necessarily make sense on mobile. It’s a wickedly exciting opportunity but there are myriad challenges to getting it right. One avenue for exploring this opportunity is through Mozilla Labs, which is about pushing the envelope towards better and brighter interaction horizons, as well as incorporating a winder community into the innovation process. This concept video explains one direction we are thinking in, and we’d love to inspire participation in thinking about other d