check [Solved] Store data into a file

1 year 11 months ago - 1 year 11 months ago #5311 by Ralf Ebert
Hi all,

is it possible to store data into a file using a script?

Best regards
Ralf Ebert

Please Log in or Create an account to join the conversation.

1 year 11 months ago #5312 by pan
Hi Ralf,

This is an example:
from java.io import BufferedWriter
from java.io import OutputStreamWriter
from java.io import FileOutputStream
from java.io import IOException

outputDirectory = "C:\\diskH\\Modelio workspace\\Scripts Jython\\3.7"
xmlcontent ='<?xml version="1.0" encoding="UTF-8"?>\n'
xmlcontent =xmlcontent+'<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initial="test">\n'
xmlcontent =xmlcontent+'</scxml>'

try:
	out = BufferedWriter(OutputStreamWriter(FileOutputStream(outputDirectory+"\\export.xml"),"UTF-8"))	
	out.write(xmlcontent)
	out.close()
except IOException:
	print "Error writing file"

You can import Java classes so if you are familiar with Java you can use Java methods for storing data in a file.

BR
The following user(s) said Thank You: Ralf Ebert

Please Log in or Create an account to join the conversation.

1 year 11 months ago #5313 by Ralf Ebert
Hi pan,

thank you very much for your fast respone.

Best regards
Ralf Ebert

Please Log in or Create an account to join the conversation.

Moderators: tma
Time to create page: 0.034 seconds
^ Back to Top