[erledigt] QtJambi : Fehler oder Java Dau

Alles zum Qt Framework für Java
Antworten
ArneStocker
Beiträge: 300
Registriert: 3. November 2004 16:15
Wohnort: Berlin

[erledigt] QtJambi : Fehler oder Java Dau

Beitrag von ArneStocker »

hallo

ich habe mal für (ganz kleines) Projekt versucht auf Java mit QtJambi umzustellen. Darin wird u.a. ein ConfigFile ausgelesen und auf Schlüsselwerte verteilt. In c++ funktioniert das einwandfrei, aber in java wird lediglich die erste zeile gelesen (soll heißen die (QtJambi) Methode

Code: Alles auswählen

{QFile}configFile.atEnd()
liefert nach dem lesen der ersten Zeile mit

Code: Alles auswählen

{QTextStream} textstream.readLine()
ein false

Code: Alles auswählen

 // ... Method for open the ConfigFile
static boolean LoadConfig(String file)
{
    // the default name should be "lux.cfg" 
    m_file = file; // remember the name of the configfile
    if (m_file.length() == 0) {
        m_file = TEXT_LUX_CFG;
    }
        
    QFile configFile = new QFile(QApplication.applicationDirPath() + "/" + m_file);
    
    if (configFile.open(QIODevice.OpenModeFlag.ReadOnly) == true) // open the file
    {
        String zeile = ""; 
        QTextStream textStream = new QTextStream(configFile);

        while (configFile.atEnd() == false)  // there are several lines in the file
        {
            // try to get the key that means until the first '='
            zeile = textStream.readLine();
            gleichPos = zeile.indexOf('=');

            // if there ist a '='
            if (gleichPos > 0)
            {
                String key = zeile.substring(0,gleichPos);                 // key =  text before '='
                String content = zeile.substring(gleichPos + 1);        // content = text after '='

                key.trim();                                                            // remove blanks at beginning and end
                key.toUpperCase();                                               // to upper case
                content.trim();                                                       // remove blanks at beginning and end

                if (	(key.length() != 0)	&&                                 // if there ist a valid key
                        (content.length() != 0)	)                                 // and a valid content
                {
                    m_keyList.add(key);                                          // key to keylist
                    m_contentList.add(content);                               // content to contentlist
                }
            }
        }
        m_isConfigFile = true;                                                   // there ist a configfile
        m_change = false;                                                        // the configparams must not be saved
        configFile.close();                                                          // close the file
    }
    return m_isConfigFile;
}
ist das jetzt ein Fehler oder habe ich in Java irgendwas verpasst (fange ich gerade erst mit an)

Gruß Arne
Antworten