java.lang.La chaîne ne peut pas être lancé à java.util.Carte

Je suis nouveau sur Java, mais pas de nouvelles pour la programmation, de sorte que mon premier projet j'ai décidé d'en créer un .txt-.csv analyseur pour quelqu'un au travail. J'ai lu chaque ligne dans le .fichier txt et de les séparer en Cartes séparées pour les sections, sous-sections, sous-sections et les sous-sections contenu. Chaque Carte est ensuite affecté à la Carte ci-dessus (ci-dessous). J'ai l'impression tout c'est très bien, mais quand j'essaie de le lire j'obtiens l'erreur suivante: "java.lang.String cannot be cast to java.util.Map". L'erreur apparaît uniquement après l'exécution du code, et non pas lors de la compilation, ni dans l'EDI NetBeans.

Mes Cartes sont dans le formulaire ci-dessous avec chaque Objet de la Carte ci-dessous: (Pourquoi ne peut-Java rendre cela facile -_- Tableaux Associatifs sont tout ce que je veux)

(Map)array=<string,Object>
(Map)subarray=<String,Object>
(Map)subsubarray=<String,Object>
(Map)subsubcontents=<String,String>

Peut-être pas le moyen le plus efficace de lire cela, le plan de convertir ceci en fonction récursive plus tard, mais voici mon code, le copier-collé de mon projet. J'ai mis des commentaires à l'endroit où j'ai trouvé l'erreur.

public static Map<String,Object> array=new HashMap<String,Object>();

/* Code for populating the following Maps and pushing them into array
<String,Object>subarray
<String,Object>subsubarray
<String,String>subsubcontents
*/

Set section=array.entrySet();
Iterator sectionI=section.iterator();
while(sectionI.hasNext()) {
    Map.Entry sectionInfo=(Map.Entry)sectionI.next();
    Map<String,Object> subMap=(Map)sectionInfo.getValue();
    Set subSet=subMap.entrySet();
    Iterator subI=subSet.iterator();
    while(subI.hasNext()) {
            Map.Entry subInfo=(Map.Entry)subI.next();
            Map<String,Object> subsubMap=(Map)subInfo.getValue();
            Set subsubSet=subsubMap.entrySet();
            Iterator subsubI=subsubSet.iterator();
            while(subsubI.hasNext()) {
                    System.out.println("test");
                    Map.Entry subsubInfo=(Map.Entry)subsubI.next();
                    Map<String,Object> subcontentsMap=(Map)subsubInfo.getValue();
/*
The above line seems to be causing the issues.
If you comment out the rest of this loop (below this comment)
the error will still appear. If you comment out the rest of this loop
(including the line above this comment) it disappears.
Power of deduction my dear Watson.
*/
                    Set subcontentsSet=subcontentsMap.entrySet();
                    Iterator keys=subcontentsSet.iterator();
                    while(keys.hasNext()) {
                        Map.Entry keyMap=(Map.Entry)keys.next();
                    }
                    Iterator values=subcontentsSet.iterator();
                    while(values.hasNext()) {
                        Map.Entry valueMap=(Map.Entry)values.next();
                    }
            }
    }
}

Toute aide serait grandement appréciée. J'ai eu du mal avec ce pour un couple de jours maintenant.

Vous pouvez poster l'ensemble de la stacktrace?
getStackTrace() renvoie [Ljava.langStackTraceElement;@c0a150

OriginalL'auteur mseancole | 2011-11-17