Tou tentando gravar um .txt e nao consigo....unc.abreCaminhoSave() retorna um file do metodo .getSelectedFile() de JFileChooser.
A classe UNC ta funcionando perfeitamente...ate porque eu tou salvando um .txt em outro metodo e ta tudo certinho!!
O problema eu acho que ta no BufferedWriter!!
Se precisar da classe OperacoesUNC fala q eu posto...
public class SorteioListener implements ActionListener{
public void actionPerformed(ActionEvent e){
OperacoesUNC unc = new OperacoesUNC();
ArrayList<Integrante> temp = new ArrayList<Integrante>();
int index;
int cont = 1;
Integrante inte;
for(Integrante integrante : listaIntegrantes){
temp.add(integrante);
}
try{
BufferedWriter writer = new BufferedWriter(new FileWriter(unc.abreCaminhoSave(true)));
writer.write("Grave poha!!");
while(!temp.isEmpty()){
inte = temp.get(sortear(temp.size()));
writer.write("Nº "+cont+" "+inte.getNome()+"\n");
cont++;
temp.remove(inte);
}
writer.close();
}
catch(Exception ex){}
}
int sortear(int tamanho){
int resultado = (int) Math.round(Math.random()*tamanho);
return resultado;
}
}
package jcadastroguj;
import java.io.*;
public class Integrante implements Serializable{
private boolean fazParte;
private String nome,email,telefone;
public void setNome(String n){
nome = n;
}
public void setEmail(String e){
email = e;
}
public void setTelefone(String t){
telefone = t;
}
public void setFazParte(boolean fp){
fazParte = fp;
}
public String getNome(){
return nome;
}
public String getEmail(){
return email;
}
public String getTelefone(){
return telefone;
}
public boolean getFazParte(){
return fazParte;
}
}