Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

229
Vistas
Java - Quirk with reading lines from a Path

I seem to be having a randomly occurring issue that I hope someone can shed light on. I am reading in a file and outputting the contents. I have one test file, which can be read in 90% of the time. However, once in a while it incorrectly reports that the test file has 0 lines. Is there a reason this is happening? I would expect that it always reads in the contents. A bare bones example is shown below:

public void foo (Path path){
    System.out.println("Exists?"+ Files.exists(path)); // Always says true
    List<String>lines = Files.readAllLines(path);
    System.out.println("NumLines:"+ lines.size()); // Sometimes 0, sometimes 7
}

I have also tried this with a BufferedReader(new FileReader(path.ToFile())) and get the same results

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda