Shaaf's blog

A technical blog about Java, Kubernetes and things that matter

Generate XML - DBMS_XMLGEN

On my way to my solution store just found this nice to use, old and easy feature. Possibilities endless, usage typically very easy.

I used the following to generate XML from sqlplus:

select dbms_xmlgen.getxml('select * from user') from dual;

Output: < ROWSET > < ROW > < TNAME >Employee< / TNAME > < TABTYPE > TABLE < / TABTYPE > < / ROW > < / ROWSET >


Doing the Locale - Danmark

The following illustrates how to get the Number format working with a danish locale.

	import java.text.NumberFormat;
	import java.util.Currency;
	import java.util.Locale;


	public class TestLocale {

	public static void main(String args[]){
		// Create a Locale for Danmark
		Locale DANMARK = new Locale("da","DK");

 		// get the currency instance for this locale.
 		Currency krone = Currency.getInstance(DANMARK);

 		// Get a Number format for the locale.
 		NumberFormat krFormat = NumberFormat.getCurrencyInstance(DANMARK);
 		// A symbol for the currency
 		String symbol = krFormat.getCurrency().getSymbol();
 		// A double amount
 		double amount = 10000.25;
		// print it out after formatting.
 		System.out.println(krFormat.format(amount));
 		}
	}

How to read a file from the JAR?

Someone just asked me this question today. And I thought might as well put it down for info.

 	public TestReadFileFromJar() throws FileNotFoundException, IOException {
        	InputStream is = getClass().getResource("txtData/states.properties");
        	read(is);
	}

In the case above txtData is placed in the jar on the root. Remmember to add the path with the “/”


Crocus - CSV Reader

Easy to use ready to go CSV File Reading utility. Read One or Multiple files into a RecordManager, quick access to the file with segmentation into Fields and Records. Merge Multiple CSV files in one. Listener to CSV Files.

Download Here

Organization: A CSV file is broken up as follows A CSVField has a group of characters A CSVRecord has a group of CSVFields A CSVFile has a group of record