Connector to Make Files

1
0
-1

Hi, I wanna add a Groovy conector to make a txt or log File with variables, constants that I can define in him. I tried the following simple but the file wasn't generated:

String filename = "C:\execution-.log"; // Fichero de lectura/escritura File f = new File(filename); // Escritura en el fichero f << "KPI:" << " ";

any solution? Thanks

1 answer

1
+2
-1

Hi.

You forgot to call the method "createNewFile()" in your script. At the end of the script, you need to add :

f.createNewFile();

Here is a tutorial on how to create file in java : http://www.mkyong.com/java/how-to-create-a-file-in-java/

Comments

Submitted by felmarlop on Mon, 01/19/2015 - 11:59

Thanks yannicklombardi, and Can I write within the file after creating it that way? (f<< "bla bla bla"). Thanks

Submitted by yannick.lombardi on Mon, 01/19/2015 - 12:07

I don't know if f<<"bla bla bla" works. I don't think this works in java. You can use a bufferedWriter if you want to write in a file. http://www.mkyong.com/java/how-to-write-to-file-in-java-bufferedwriter-e...

Notifications