CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   STAR-CCM+ (https://www.cfd-online.com/Forums/star-ccm/)
-   -   Reading data from textfile into macro (https://www.cfd-online.com/Forums/star-ccm/180844-reading-data-textfile-into-macro.html)

harry123 December 1, 2016 09:28

Reading data from textfile into macro
 
Hi,

I wish to read some parameters from a text file and use it to assign values in a starccm macro. The code looks something like this:

java.io.FileReader freader = new java.io.FileReader("pathToFile");
java.io.BufferedReader inputFile=new java.io.BufferedReader(freader);

//courseName=inputFile.readLine();

while ((line=inputFile.readLine())!= null) {
String[] arrayline = line.split("\\s+");
data[i] = Double.parseDouble(arrayline[1]);
}

inputFile.close();

R = data[0];
L = data[1];
r = data[2];
l = data[3];
angle = data[4];

I'm getting a error:unreported exception, java.io.FileNotFoundException; must be caught or declared to be thrown.

I'm not too familiar with java, but still have tried all possible suggestions given in java forums. I'm not sure if the issue is related to how java scripts work in StarCCM.

It would be great help if someone can help me out !

me3840 December 1, 2016 14:45

You are not telling Java what to do in case the file you specify doesn't exist.
https://examples.javacodegeeks.com/j...und-exception/


All times are GMT -4. The time now is 02:20.