You can create a regular csv file with java.io.file package components. Or you can go after Apache POI and JExcelApi for Microsoft Excel file format. You may find lots of examples in the specified API documentation pages.
Assuming that you have to do it with your own code. Other wise you can export data with any pl/sql editor by hand.