Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

152
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda