I want to create a data file(.txt) with the data in a mysql table. (of course i did that)

try {
					// Create the statement
					

					 //Export the data
				String filename = "test.xls";
				String tablename = "test";
	c.getData("SELECT * INTO OUTFILE '"+ filename + "' FROM " + tablename);
				System.out.println(filename);
				} catch (Exception e) {}

This create the test.xls file in the folder that the java class in.

I want to make that file created in a specific folder rather than the folder that the java class is in.

**getdata() method is OK.

How can I do that?

Recommended Answers

All 2 Replies

Make the file name the complete path, startiung with c: or whatever.

ps: Don't forget that \ is the escape character in Java Strings - so to put a \ in the file path you need to code \\

pps:
Rather than absolute paths that may not work from one machine to another, you can also get the paths to useful folders in a system-independent way with calls like
System.getProperty("user.home")

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.