:cry:Bom Dia ! Amigos, tenho uma interface gráfica no qual entro com 5 dezenas em 5 caixas JTextField tipo 23 45 67 68 72 e quando faço o evento no botão apostar ele tem que procurar dentro de um arquivo txt o indice e as dezenas comparar linha por linha no caso se já tiver saido essas dezenas ele apresenta uma mensagem e não inclui a minha aposta, caso contrário ele acrescenta a minha aposta na última linha, porém antes de comparar eu precisaria colocar o vetor que estou apostando em ordem crecente o código abaixo não está comparando e nem colocando em ordem, alguém poderia me ajudar ?
O arquivo txt ficaria assim.
1 23 65 69 72 77
2 1 12 25 56 67
public void Apostar () {
Sorteados[0] = id;
Sorteados[1] = txt1.getText();
Sorteados[2] = txt2.getText();
Sorteados[3] = txt3.getText();
Sorteados[4] = txt4.getText();
Sorteados[5] = txt5.getText();
String[] vetorRetorno = (String[])Sorteados.clone();
int tam = vetorRetorno.length;
int lin, col;
boolean trocou; //verifica se houve trocas
for (lin = 0; lin < (tam - 1); lin++)
{
trocou = false;
for (col = 0; col < (tam - 1 - lin); col++)
if (Integer.parseInt(vetorRetorno[col]) > Integer.parseInt(vetorRetorno[col + 1]))
{
}
String strArq = "C:\\arquivo.txt";
char espaco = ' ';
try
{
FileOutputStream fos = new FileOutputStream( strArq, true );
PrintStream ps = new PrintStream( fos, true );
File file = new File("c://arquivo.txt");
FileReader reader = new FileReader(file);
BufferedReader leitor = new BufferedReader(reader);
String linha;
String idArq = " ";
String dezena1 = " ";
String dezena2 = " ";
String dezena3 = " ";
String dezena4 = " ";
String dezena5 = " ";
Apostas[0] = idArq;
Apostas[1] = dezena1;
Apostas[2] = dezena2;
Apostas[3] = dezena3;
Apostas[4] = dezena4;
Apostas[5] = dezena5;
StringTokenizer separador;
do
{
linha = leitor.readLine();
if( linha != null ) {
separador = new StringTokenizer(linha, " ");
for (x=0; x < Apostas.length; x++){
Apostas[x] = separador.nextToken();
for(i=0; i < Sorteados.length; i++) {
ps.print(Sorteados[i] + espaco);
if (txt1.getText().equals(dezena1) & txt2.getText().equals(dezena2) & txt3.getText().equals(dezena3) & txt4.getText().equals(dezena4) & txt5.getText().equals(dezena5)){
System.out.println("Tem Dezenas Iguais");
}
}
}
}
}while ( linha != null );
leitor.close();
reader.close();
}
catch( Exception e ) {
e.printStackTrace();
{
}
}}
}