Map HashMap qual é o problema?

Fala galera tudo certo?

Bem é o seguinte eu estou tentando ler um arquivo e seprar o conteudo dele e tals… o conteudo do arquivo é algo como isso…

[bloco comando 1]
blabla = “opa”
numero = 1

[bloco comando 2]
200,098,99

ai eu estou tentando colocar o nome do bloco com seus valores… a ideia que estou usando é isso:

[code]
public Map<String, ArrayList> mapeamento = new HashMap<String, ArrayList>();

public void mount(){
String[] mount = conteudo.split("\n");
ArrayList propriedades = new ArrayList();
String blocoNome = “”;

	for(int i=0; i < mount.length; i++){
		Pattern pesq = Pattern.compile("\[(.*?)\]");
		Matcher result = pesq.matcher(mount[i]);
		
		if(result.matches()){
			if(blocoNome != ""){
				System.out.println(blocoNome + " = " + propriedades);

				mapeamento.put(blocoNome,propriedades);
			}
			blocoNome = result.group(1);
			propriedades.clear();
		}else{
			propriedades.add(mount[i]);
		}
	}
}[/code]

só que está tendo um problema ali dentro do if blocoNome vcs vão ver eu estou printando para ver se ele está me retornando o que quero para gravar em meu mapeamento ele printa certo e então eu dou o put para amazerna o conteudo e tals… mais quando eu dou um get(“bloco do comando”) eu percebi que ele retorna para todos os bloco sempre o ultimo bloco lido…

Será que teria alguma outra logica para eu conseguir ler isso e poder recuperar as coisas quando eu chamar o nome do bloco?

Você já viu todos os conteúdos do Map? Deu um print nele?

Ou você está colocando todos os valores na mesma chave, ou está usando a chave errada pra comparar.

Olha o resultado…

no print dentro do ele printa isso:

Info = [name = "Default", author = "Elecbyte"] Files = [spr = system.sff, snd = system.snd, logo.storyboard =, intro.storyboard =, select = select.def, fight = fight.def, font1 = font/f-4x6.fnt, font2 = font/f-6x9.fnt, font3 = font/jg.fnt] Music = [title.bgm =, title.bgm.loop = 1, select.bgm =, select.bgm.loop = 0, vs.bgm =, vs.bgm.loop = 1] Title Info = [fadein.time = 10, fadeout.time = 10, menu.pos = 159,158, menu.item.font = 3,0,0, menu.item.active.font = 3,5,0, menu.item.spacing = 0, 13, menu.itemname.arcade = "ARCADE", menu.itemname.versus = "VS MODE", menu.itemname.teamarcade = "TEAM ARCADE", menu.itemname.teamversus = "TEAM VS", menu.itemname.teamcoop = "TEAM CO-OP", menu.itemname.survival = "SURVIVAL", menu.itemname.survivalcoop = "SURVIVAL CO-OP", menu.itemname.training = "TRAINING", menu.itemname.watch = "WATCH", menu.itemname.options = "OPTIONS", menu.itemname.exit = "EXIT", menu.window.margins.y = 12, 8, menu.window.visibleitems = 5, menu.boxcursor.visible = 1, menu.boxcursor.coords = -58,-10,57,2, cursor.move.snd = 100,0, cursor.done.snd = 100,1, cancel.snd = 100,2] TitleBGdef = [bgclearcolor = 0,0,0] TitleBG 0 = [type = parallax, spriteno = 5, 1, start = 0, 145, width = 400, 1200, yscalestart = 100, yscaledelta = 1, tile = 1,1, velocity = -1] TitleBG 1 = [type = normal, spriteno = 5, 2, start = -160, 145, trans = sub] TitleBG 2 = [type = normal, spriteno = 5,0, start = 0, 10, tile = 1,2, velocity = -1, mask = 0] TitleBG 3 = [type = normal, spriteno = 0,0, start = 0, 40, mask = 1, trans = add] Select Info = [fadein.time = 10, fadeout.time = 10, rows = 2, columns = 5, wrapping = 0, pos = 90,170, showemptyboxes = 0, moveoveremptyboxes = 0, cell.size = 27,27, cell.spacing = 2, cell.bg.spr = 150,0, cell.random.spr = 151,0, cell.random.switchtime = 4, p1.cursor.startcell = 0,0, p1.cursor.active.spr = 160,0, p1.cursor.done.spr = 161,0, p1.cursor.move.snd = 100,0, p1.cursor.done.snd = 100,1, p1.random.move.snd = 100,0, p2.cursor.startcell = 0,4, p2.cursor.active.spr = 170,0, p2.cursor.done.spr = 171,0, p2.cursor.blink = 1, p2.cursor.move.snd = 100,0, p2.cursor.done.snd = 100,1, p2.random.move.snd = 100,0, random.move.snd.cancel = 0, stage.move.snd = 100,0, stage.done.snd = 100,1, cancel.snd = 100,2, portrait.offset = 0,0, portrait.scale = 1,1, title.offset = 159,13, title.font = 3,0,0, p1.face.offset = 18,13, p1.face.scale = 1,1, p1.face.facing = 1, p2.face.offset = 301,13, p2.face.scale = 1,1, p2.face.facing = -1, p1.name.offset = 10,162, p1.name.font = 3,4,1, p2.name.offset = 309,162, p2.name.font = 3,1,-1, stage.pos = 160,237, stage.active.font = 3,0,0, stage.active2.font = 3,2, stage.done.font = 3,0, teammenu.move.wrapping = 1, p1.teammenu.pos = 20, 30, p1.teammenu.selftitle.font = 3,0, 1, p1.teammenu.selftitle.text = Select team mode, p1.teammenu.enemytitle.font = 3,0, 1, p1.teammenu.enemytitle.text = Opponent team mode, p1.teammenu.move.snd = 100,0, p1.teammenu.value.snd = 100,0, p1.teammenu.done.snd = 100,1, p1.teammenu.item.offset = 0,20, p1.teammenu.item.spacing = 0,15, p1.teammenu.item.font = 3,0, 1, p1.teammenu.item.active.font = 3,3, 1, p1.teammenu.item.active2.font = 3,0, 1, p1.teammenu.item.cursor.offset = -10, 0, p1.teammenu.item.cursor.anim = 180, p1.teammenu.value.icon.offset = 60,1, p1.teammenu.value.icon.spr = 181,0, p1.teammenu.value.empty.icon.offset = 60,1, p1.teammenu.value.empty.icon.spr = 182,0, p1.teammenu.value.spacing = 6,0, p2.teammenu.pos = 299, 30, p2.teammenu.selftitle.font = 3,0, -1, p2.teammenu.selftitle.text = Select team mode, p2.teammenu.enemytitle.font = 3,0, -1, p2.teammenu.enemytitle.text = Opponent team mode, p2.teammenu.move.snd = 100,0, p2.teammenu.value.snd = 100,0, p2.teammenu.done.snd = 100,1, p2.teammenu.item.offset = 0,20, p2.teammenu.item.spacing = 0,15, p2.teammenu.item.font = 3,0, -1, p2.teammenu.item.active.font = 3,1, -1, p2.teammenu.item.active2.font = 3,0, -1, p2.teammenu.item.cursor.offset = 10, 0, p2.teammenu.item.cursor.anim = 190, p2.teammenu.value.icon.offset = -60,1, p2.teammenu.value.icon.spr = 191,0, p2.teammenu.value.empty.icon.offset = -60,1, p2.teammenu.value.empty.icon.spr = 192,0, p2.teammenu.value.spacing = -6,0] SelectBGdef = [] SelectBG 0 = [type = normal, spriteno = 100,0, layerno = 0, start = 0,0, tile = 1,1, velocity = -1, -1] SelectBG 1 = [type = normal, spriteno = 100,1, layerno = 0, start = 0, 166, delta = 0,0, tile = 1,0, trans = sub, window = 85,0, 235,239, velocity = -1, 0] SelectBG 2.A = [type = normal, spriteno = 102,0, layerno = 0, start = 0, 2, delta = 0,0, tile = 1,0, trans = sub, velocity = -1, 0] SelectBG 2.B = [type = normal, spriteno = 102,1, layerno = 0, start = 0, 2, delta = 0,0, tile = 1,0, trans = add, velocity = -3, 0] SelectBG 2.C = [type = normal, spriteno = 102,2, layerno = 0, start = 0, 2, delta = 0,0, tile = 1,0, trans = add, velocity = -6, 0] VS Screen = [time = 150, fadein.time = 15, fadeout.time = 15, p1.pos = 20,31, p1.facing = 1, p1.scale = 1,1, p2.pos = 299,31, p2.facing = -1, p2.scale = 1,1, p1.name.pos = 78,190, p1.name.font = 3,0,0, p2.name.pos = 241,190, p2.name.font = 3,0,0] VersusBGdef = [] VersusBG 1 = [type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = 0,1.5] VersusBG 2 = [type = normal, spriteno = 100,1, start = 20,13, tile = 1,1, trans = sub, window = 19,30, 140,171, velocity = -2, 0] VersusBG 3 = [type = normal, spriteno = 100,1, start = 20,13, tile = 1,1, trans = sub, window = 179,30, 300,171, velocity = 2, 0] VersusBG 4 = [type = anim, actionno = 200, layerno = 1, start = 0,95] Begin Action 200 = [200,4, 0,0, 1, 200,3, 0,0, 2, 200,2, 0,0, 3, 200,1, 0,0, 4, 200,0, 0,0, 8, 200,5, 0,0, 3, 200,6, 0,0, 3, 200,7, 0,0, 3, 200,8, 0,0, 3, 200,0, 0,0, -1] Demo Mode = [enabled = 1, select.enabled = 0, vsscreen.enabled = 0, title.waittime = 600, fight.endtime = 1500, fight.playbgm = 0, fight.bars.display = 0, intro.waitcycles = 1, debuginfo = 0] Continue Screen = [enabled = 1] Game Over Screen = [enabled = 0, storyboard =] Win Screen = [enabled = 1, wintext.text = Congratulations!, wintext.font = 2,0,0, wintext.offset = 159,70, wintext.displaytime = -1, wintext.layerno = 2, fadein.time = 32, pose.time = 300, fadeout.time = 64] Default Ending = [enabled = 0, storyboard =] End Credits = [enabled = 0, storyboard =] Survival Results Screen = [enabled = 1, winstext.text = Rounds survived: %i, winstext.font = 3,0,0, winstext.offset = 159,70, winstext.displaytime = -1, winstext.layerno = 2, fadein.time = 32, show.time = 300, fadeout.time = 64, roundstowin = 5] Option Info = [cursor.move.snd = 100,0, cursor.done.snd = 100,1, cancel.snd = 100,2] OptionBGdef = []

Veja que tenho Chave = ArrayList

agora quando eu deou um
System.out.println(System.out.println(mapeamento));

depois que termina totalmente o loop ele mostra isso:

{SelectBG 1=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], SelectBG 0=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], SelectBG 2.B=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], SelectBG 2.A=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], OptionBGdef=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], Win Screen=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], Option Info=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], Game Over Screen=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], SelectBG 2.C=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], Demo Mode=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], VersusBG 3=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], VersusBG 4=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], VersusBG 1=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], VersusBG 2=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], Files=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], Begin Action 200=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], Music=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], End Credits=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], Continue Screen=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], Title Info=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], Select Info=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], TitleBG 0=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], TitleBGdef=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], Survival Results Screen=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], TitleBG 2=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], TitleBG 1=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], TitleBG 3=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], Default Ending=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], VersusBGdef=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], VS Screen=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], Info=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1], SelectBGdef=[type  = normal, spriteno = 100,0, start = 0,0, tile  = 1,1, velocity = -1, -1]}

separando por linha isso veja:

{ SelectBG 1=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], SelectBG 0=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], SelectBG 2.B=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], SelectBG 2.A=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], OptionBGdef=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], Win Screen=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], Option Info=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], Game Over Screen=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], SelectBG 2.C=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], Demo Mode=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], VersusBG 3=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], VersusBG 4=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], VersusBG 1=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], VersusBG 2=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], Files=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], Begin Action 200=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], Music=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], End Credits=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], Continue Screen=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], Title Info=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], Select Info=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], TitleBG 0=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], TitleBGdef=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], Survival Results Screen=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], TitleBG 2=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], TitleBG 1=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], TitleBG 3=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], Default Ending=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], VersusBGdef=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], VS Screen=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], Info=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1], SelectBGdef=[type = normal, spriteno = 100,0, start = 0,0, tile = 1,1, velocity = -1, -1] }

=/

viu num sei o porque ele ta fazendo isso se no primeiro print que está dentro do loop ele faz ferto ele retorna o que quero agora quando termina o loop ele me mostra isso…

Olha achei o porque ta fazendo isso nesse pequeno codigo que eu fiz de teste…
eu tenho o seguinte codigo

Map<String,ArrayList> mapa = new HashMap<String, ArrayList>(); ArrayList<String> arr = new ArrayList<String>(); arr.add("opa"); mapa.put("valor",arr); System.out.print(mapa.get("valor"));

Nesse codigo ele vai e imprime o arraylist Opa

agora nesse outro

Map<String,ArrayList> mapa = new HashMap<String, ArrayList>(); ArrayList<String> arr = new ArrayList<String>(); arr.add("opa"); mapa.put("valor",arr); arr.clear(); System.out.print(mapa.get("valor"));

Ele não imprime sendo que eu estou dando um clear depois de ter atribuirdo o valor… alguem sabe me explicar do porque e qual a maneira correta?

pois eu tenho esse mapa.put() dentro de um for e eu preciso resetar o ArrayList a cada 5 voltas pois apos 5 voltas eu mudo o nome e tals…