Ver Mensaje Individual
  #5 (permalink)  
Antiguo 05/12/2009, 21:50
Fabj21
 
Fecha de Ingreso: mayo-2009
Mensajes: 46
Antigüedad: 15 años
Puntos: 0
Respuesta: Buen Dia, una duda sobre manejo de un archivo.

Cita:
Iniciado por Asezin0 Ver Mensaje
mira, si es lo que pienso es un tema un poco complejo que tenemos que discutir y estoy dispuesto a ayudarte, porque me interesó el tema y escapa de la programacion ordinaria...te felicito por eso

pero antes necesito que seas bien claro en lo que deseas... una breve explicacion de lo que necesitas.

Saludos
muchas gracias por responder de nuevo

te anexo algo del codigo que tengo
Código PHP:
public class web {
    
    
/** Creates a new instance of Main */
     
    /**
     * @param args the command line arguments
     */
    
public static void main(String[] argsthrows FileNotFoundException {
        
int contador;
        
ArrayList<Integerlista = new ArrayList<Integer>();
        
Scanner scn = new Scanner(new File("in.txt"));
        try {
        
PrintWriter fileOut = new PrintWriter(new FileWriter("out.txt"));
        
int ciudadabuscar scn.nextInt();
        
int aerolinea scn.nextInt();
        
int bandera=0;
        while (
scn.hasNextLine()){
                
String cad scn.nextLine();
                
StringTokenizer st = new StringTokenizer(cad," ");
         while (
st.hasMoreTokens())
         {
                
String t st.nextToken(); 
                
lista.add Integer.parseInt(t) );
         }
           
int a[]= new int[lista.size()];
           for (
int x=0x<lista.size(); x++)
                        {
                        
a[x] = lista.get(x);
                        }
                      for (
int x=0x<lista.size(); x++)
                        {
               for (
x=1;x<lista.size();x++){
                        if (
ciudadabuscar == a[0] && aerolinea == a[1])//tenia x=1
                
{
                            for (
x=2;x<lista.size();x++)
                            { 
fileOut.printf("%d ",a[x]);
                              
ciudadabuscara[2];
                              
bandera 1;}
                }
               }
                         }
                     
lista.clear();
        }
        if(
bandera==0){
        
fileOut.println("No hay destinos posibles por esta línea");
        }
        
fileOut.close();
        }catch(
FileNotFoundException ex){}catch(IOException ex){}
        }

brevemente se puede observa que actualizo ciudad a buscar...y es ahi donde falta algo de programacion..aunado al hecho que hago lista.clear...limpio lo valores que ya lei de la lista... tengo k utilizar otra forma de leer los archivos

asi estaria el archivo de texto de entrada:
2 5
0 9 2 3 4
1 2 3 9
1 5 4
2 0 0 5 6
2 5 1 9
4 6 1 5
4 9 1 8
9 1 4 8
9 5 0

y la salida seria:

1 9 4 0

mucha gracias por el interes