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

150
Vistas
How to pass the file path as an argument in RandomFileAccess Object in android?

There is a small problem in the following code that it is unable to find the text file src/main/res/raw/dictionary.txt:

 RandomAccessFile ifl = new RandomAccessFile("android.resource://" 
                               + getPackageName() + "/" + R.raw.dict , "r");

Is there any other way by which the text file can successfully be found and opened? Is there a way if we keep these files in 'assets' folder and then access? Plz suggest.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

you can better use InputStream to read text in raw folder file ,

 public String readRawFile()
{
     StringBuilder builder = new StringBuilder();
     InputStream in = getResources().openRawResource(R.raw.yourfile);
  try {
       int count = 0;
       byte[] bytes = new byte[32768];
       while ( (count = in.read(bytes,0, 32768)) > 0) {
           builder.append(new String(bytes, 0, count));
       }

       in.close();
   } catch (IOException e) {
       e.printStackTrace();
   }
   return builder.toString();
}
over 4 years ago · Santiago Trujillo Denunciar
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