Javier,
Are you sure your file doesn't end in a blank line?  You should indent your
code and restructure your while loop so that the while test condition is
((linea = buffer.readline()) != null)
Why don't you also put a System.out.println("linea = '" + linea + "'"); as
the first line in your while clause.


Regards,

Richard

At 09:08 AM 11/29/2001 +0100, you wrote:
>Hi everyone. Yesterday i made a question abaout reading a file and getting
>some text from it. I made it. But it continues to read it all over again.
>Does anybody know how to tell it to stop at the end of file? (ala EOF in
>ASP). The code is this:
>
>
>public void datosconexion() {
>  System.out.println("empieza datosconexion");
>  try{
>  File noticias_conf=new File("C:/noticias_conf.txt");
>  FileReader fr=new FileReader(noticias_conf);
>  char resultado;
>  //fr.
>  //int valor=fr.read(char resultado,1,3);
>  BufferedReader buffer=new BufferedReader(fr);
>
>
>  String linea=new String();
>
>  linea=buffer.readLine();
>  while(linea!=null){
>   int pos_url=0;
>   pos_url=linea.indexOf("eroski.url");
>   if (pos_url!=-1){
>   url=linea.substring(pos_url+11,linea.length());
>   System.out.println("la url es "+url);
>   }
>   int pos_user=0;
>   pos_user=linea.indexOf("eroski.user");
>   if (pos_user!=-1){
>   user=linea.substring(pos_user+11,linea.length());
>   System.out.println("el user es "+user);
>   }
>   int pos_password=0;
>   pos_password=linea.indexOf("eroski.password");
>   if (pos_password!=-1){
>   password=linea.substring(pos_password+11,linea.length());
>   System.out.println("el password es "+password);
>   }
>
>   linea=buffer.readLine();
>   //buffer.close();
>// I think here is going through all the while all over again. How can i
>//stop it at the EOF?
>   System.out.println("valor de linea"+linea);
>  }
>  System.out.println("HE salido del bucle bien");
>  System.out.println(linea);
>  //int valor=buffer.read();
>  //System.out.println(valor);
>  /*int pos_url;
>  while (linea
>  if (linea.indexOf("eroski.url")!=-1){
>   }
>  System.out.println(" empieza en :"+linea.indexOf("eroski.url"));*/
>
>  }
>  catch(IOException io){
>   System.out.println("Execpcion io");
>   System.out.println(io.getMessage());}
>  }
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to