Connector to Make Files
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
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
Thanks yannicklombardi, and Can I write within the file after creating it that way? (f<< "bla bla bla"). Thanks
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...