I have a file that is tab separated. i read it in as an arraylist<string> how can i print out only the second section of the file?

That depends what "second section" means. If you can't be more specific than that, you have little chance of getting a program to do something with it.

the file is tab separated into three sections.

section1 section2 section3

i only want to read section2

Then use String.split() to separate it and read the second element of the result.

array is an arraylist<string>

for (int i = 0; i<array.size(); i++)
        {
            System.out.println(array.get(i).split(" "));
            
        }

i get: [Ljava.lang.String;@ca0b6

i am supposed to get "10.0.0.2"

Did you read the api doc on split() at all?

yes and according to the instructions that is how u should use it.

Really? Because this particular part would seem to be clearly saying something else

Returns:
the array of strings computed by splitting this string around matches of the given regular expression

Notice the array part.

(Also, there does not appear to be anyone named "u" here at the moment. Use proper English.)

i read it again and i still understand the same thing.

i obiously dont understand how to use it.

can you help me out or not.

It splits on a particular expression, which in your case should be tab, and returns an array of the pieces. If you want the second section then you just need the second element of that array.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.