Question: ```
imgTest.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    final AlertDialog.Builder mBuilder  =   new AlertDialog.Builder(getApplicationContext());
                                    mBuilder.setTitle("Location Available!");
                                    LayoutInflater inflater =   getLayoutInflater();
                                    View convertView        =   inflater.inflate(R.layout.reclycer_data, null);

                                    RecyclerView list       =   convertView.findViewById(R.id.recView);
                                    list.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
                                    list.setAdapter(adapter);
                                    AlertDialog dialog      =   mBuilder.create();
                                    dialog.show();
                                }
                            });

```

I want to show my Recyclerview in AlertDialog like the code, I'm pretty sure i already follow in the videos but its always force close when i open my alertDialog. Can you guys help me? i'm new use android studio

Answer: 
Assuming that you know the number of lines your file has, you can use this code. Also note that it more efficient to read it as a BufferedReader and pass it to the scanner.

I have tried to keep it as simple as possible, but if you have any doubts feel free to ask.

```
public int[] readFile(String filePath)throws Exception
    {
        int[] array = new int[100];
        Scanner sc = new Scanner(new BufferedReader(new FileReader(new File(filePath))));
        for(int i=0;sc.hasNextLine();i++) 
        {
        array[i]=Integer.parseInt(sc.nextLine());
        }
        return array;
    }

```
try this 

```
public Integer[] ReadFromFile(String fileName) {
        List listInt = new LinkedList<Integer>();
        try {
            Scanner input = new Scanner(new File(fileName));

            while (input.hasNextLine()) {
                String value = input.nextLine();
                listInt.add(Integer.parseInt(value));
                System.out.println(value);
            }
            input.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return (Integer[]) listInt.stream().toArray();
    }

```