0

I'm a beginner at java programming. I need help how to read a csv file by (tab) and store file to ArrayList and how to read a specific cell from the file. Here's my code:


    public static void main (String[] args){
           String file_Name = "info.txt";
               File file = new File(file_Name);
           try {

               Scanner inputStream = new Scanner(file);
                while (inputStream.hasNext()){
                    String data = inputStream.next();
                    String [] values;
                    String delimeter;
                   delimeter = "\tab";
                   values = data.split(delimeter);

                }
                inputStream.close();

           } catch (FileNotFoundException e) {
               e.printStackTrace();
           }

       }

text file
Sweater gold    55.5 
Jeans   silver  68.5  
Hat gold    20.0

1 Answer 1

0

The tab delimeter is '\t' not '\tab'. if you need to read specific cell in an excel you need to use a library like apache poi

Sign up to request clarification or add additional context in comments.

2 Comments

How to store file to arraylist, could you help me, please?
@ayoubosman - does this answer your question? How to read a .csv file into an array list in java?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.