javamatrixjama

Jama Matrix printwriter error


I am using JAMA matrix in my project. I need to write down a Jama matrix in text file. For that I write down this code.

package Xdata;
import Jama.Matrix;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;


public class File_r {
public static void main(String args[]) {


 Matrix A = new Matrix(10, 10);
    try {
        PrintWriter write1 = new PrintWriter(new File("/home/robotics//IdeaProjects/Data_arrange/src/Xdata/mu_X.txt"));
        A.print(PrintWriter write1,9,6);// error in this line
     }
    catch(FileNotFoundException ex) {
        System.out.println(ex);

        }
    }
}

But it throws errors:

/home/robotics/IdeaProjects/Data_arrange/src/Xdata/File_r.java
Error:(13, 32) java: ')' expected
Error:(13, 33) java: not a statement
Error:(13, 39) java: ';' expected

I wtite down this code in intellj idea. Can any one tell me why I get this error?


Solution

  • I did check the Jama api for Matrix.java. it looks you are trying to use the print method with three parameter in the below snippet . please re-write it correctly.

    fix it as below

     A.print(write1,9,6);// error in this line