I have to change this code (c++) on Java, can you help me.

QAbstractItemModel *MainWindow::modelFromFile(const QString& fileName)
     QFile file(fileName);
     if (!file.open(QFile::ReadOnly))
         return new QStringListModel(completer);

 #ifndef QT_NO_CURSOR
     QStringList words;

     while (!file.atEnd()) {
         QByteArray line = file.readLine();
         if (!line.isEmpty())
             words << line.trimmed();

 #ifndef QT_NO_CURSOR
     return new QStringListModel(words, completer);

Find out what it is suppossed to be doing and reprogram it in Java. Trying to achieve a 1-to-1 translation is an exercise in futility, and, even if you do get it to run, it is not likely to be at all performant.