Java - ayuda codigo

 
Vista:

ayuda codigo

Publicado por david (2 intervenciones) el 22/05/2012 02:58:42
ayuda quiero mostrar los comercios en pantalla pro no se como ubicarme urgente les envio mi codigo gracias

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import java.io.*;
import javax.swing.JOptionPane;
 
/**
 *
 * @author luis padron
 */
public class JavaApplication5 {
 
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        // TODO code application logic        
        atributicos[] atri;
        atri = new atributicos[5];
        String[] valores = null;
 
        FileReader LectorArchivo;
       try{
             LectorArchivo = new FileReader ("C:/Users/luis padron/Documents/NetBeansProjects/nombre/proyecto.txt");
        }catch(FileNotFoundException err){
            JOptionPane.showConfirmDialog(null, "archivo no encontrado \n" + err.getMessage());
            return;
        }
 
		BufferedReader textoArchivo;
		textoArchivo = new BufferedReader (LectorArchivo);
                int casilla;
                casilla = 0;
                while (casilla < atri.length) {
 
                    String lineaTexto;
                    try{
                        lineaTexto = textoArchivo.readLine();
                    }catch(IOException err){
                        JOptionPane.showMessageDialog(null, err.getMessage());
                        return;
                    }
 
                    if (lineaTexto == null)  {
                        break;
                }
                    if (lineaTexto.equals("")) {
                        break;
                    }
 
                     valores = lineaTexto.split(";");
                     int i = 0;
                    atri[casilla] = new atributicos();
                    atri[casilla].setNombre(valores[i+0]);
                    atri[casilla].setEstado(valores[i+1]);
                    atri[casilla].setRif(valores[i+2]);
                    atri[casilla].setDireccion(valores[i+3]);
                    atri[casilla].setTelefono(valores[i+4]);
                    atri[casilla].setPag_web(valores[i+5]);
                    atri[casilla].setCorreo(valores[i+6]);
                    atri[casilla].setTags(valores[i+7]);
 
 
 
                    casilla++;
                    }
 
                String mostrar;
                mostrar = "" ;
 
                casilla = 0;
                while( casilla < atri.length ){
 
                 if(atri[casilla] != null) {
                 mostrar = mostrar + atri[casilla].getNombre() + "\n" + atri[casilla].getEstado() +
                        " " + atri[casilla].getDireccion() + " " + atri[casilla].getTelefono() +
                        " " + atri[casilla].getPag_web() + " " + atri[casilla].getCorreo() +
                        " " + atri[casilla].getTags() +"\n";
                 }
 
                casilla++;
                }
                System.out.println(mostrar);
                String leer;
              System.out.println("elija su comercio a buscar");
                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                leer = br.readLine();
               boolean j;
                j = false;
                int i;
 
       for (i=0; i<valores[i].length(); i++)
 
           if (valores[i].equals(leer) ) {
 
               j= true;
 
                }
 
 
      System.out.println(valores[i]);
 
    }
 
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

ayuda codigo

Publicado por yensei (2 intervenciones) el 23/05/2012 17:58:41
No sabes como ubicarte? deberias empezar explicando mejor tu problema, por lo menos informá cual es tu objetivo con ese codigo y cual es el resultado q te esta dando
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 22
Ha aumentado 1 puesto en Java (en relación al último mes)
Gráfica de Java

ayuda codigo

Publicado por nelson e (2 intervenciones) el 27/05/2012 19:50:48
buenas
reemplaza este codigo por el coloco abajo

1
2
3
4
5
6
7
8
9
10
11
while( casilla < atri.length ){
 
                 if(atri[casilla] != null) {
                 mostrar = mostrar + atri[casilla].getNombre() + "\n" + atri[casilla].getEstado() +
                        " " + atri[casilla].getDireccion() + " " + atri[casilla].getTelefono() +
                        " " + atri[casilla].getPag_web() + " " + atri[casilla].getCorreo() +
                        " " + atri[casilla].getTags() +"\n";
                 }
 
                casilla++;
                }

coloca este
1
2
3
4
5
6
for(int i=0;i<atri.leng;i++){
 System.out.println(atri[casilla].getNombre() + "\n" + atri[casilla].getEstado() +
                        " " + atri[casilla].getDireccion() + " " + atri[casilla].getTelefono() +
                        " " + atri[casilla].getPag_web() + " " + atri[casilla].getCorreo() +
                        " " + atri[casilla].getTags() +"\n");
}

y listo deberia funcionarte, tendra tal cual error pero seran de sintaxis revisalo est codigo te servira.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar