Writing to a file.
The following example will write the text “Sample Text” to c:/test.csv.
If test.csv doesn’t already exist then it will be created
String fileName = “c:/test.csv”;
try {
BufferedWriter out = new BufferedWriter(new FileWriter(fileName));
out.write(“Sample Text”);
out.close();
} catch (IOException e) {
}
Posts Tagged ‘output’
How To Write To A Flat File (CSV, TEXT etc.)
February 4, 2009JAVA – JFreeChart – How To Save a JFreeChart to JPEG File
November 5, 2008
A quick how to use JFreeChart quide can be found at- http://robbamforth.wordpress.com/2008/10/30/java-jfreechart-graphs-and-charts-in-java/
I wanted to be able to output the the charts to a picture file (JPEG) programatically. After a bit of research I got the following methods to paint the chart and output the image to a file.
Add these 2 methods to the class that creates the charts:
Method [...]
SQL – Output Data from SQL Server To File – BCP
November 3, 2008The following BCP command selects data from a table called CUSTOMERS in the DATA database and exports it to a file called FOO_REPORT.CSV:
declare @bcpcommand varchar(1000)
SET @bcpcommand = ‘bcp “SELECT id, title, forename, surname, product FROM DATA.dbo.customers where product = ”FOO”” queryout C:\reports\FOO_REPORT.CSV -c -T”‘
EXEC master..xp_cmdshell @bcpcommand
You can also output to .XLS and .TXT.