Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

How to save data from parameters to a .txt file?

Please login with a confirmed email address before reporting spam

Hello! I have very simple comsol application with two input fields. I want to save this data to a .txt file. I have tried to use JFileChooser from javax.swing but in my case comsol has displayed an error:

  • Resource specification not allowed here for source level below 1.7*

Question: how to save two field to a txt file?


1 Reply Last Post 2019年1月14日 GMT-5 12:40

Please login with a confirmed email address before reporting spam

Posted: 6 years ago 2019年1月14日 GMT-5 12:40
Updated: 6 years ago 2019年1月14日 GMT-5 12:41

If you need to save some data to some .txt file you must use this code:

String data = "Some data which need to save";

writeFile("temp:///my_data.txt", data);

fileSaveAs("temp:///my_data.txt");

Firstly, you should write the data you want to save in the string (line 1); Secondly, you shoud choose the format to save the data (in my case I chose .txt). Then select the default name of file (in my code it's mydata); When you run the command "fileSaveAs" comsol will open the save data dialog box.

N.B. in my case, Introduction to application builder (from comsol installation directory) did not contain this information. But in internet here's more detailed manual.

If you need to save some data to some .txt file you must use this code: > String data = "Some data which need to save"; > > writeFile("temp:///my_data.txt", data); > > fileSaveAs("temp:///my_data.txt"); Firstly, you should write the data you want to save in the string (line 1); Secondly, you shoud choose the format to save the data (in my case I chose **.txt**). Then select the default name of file (in my code it's mydata); When you run the command "fileSaveAs" comsol will open the save data dialog box. **N.B.** in my case, Introduction to application builder (from comsol installation directory) did not contain this information. But in internet [here's more detailed manual](https://cdn.comsol.com/documentation/5.4.0.246/ApplicationProgrammingGuide.zh_CN.pdf).

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.