Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

how to add elements into java string array?

807600Nov 13 2007 — edited May 4 2009
I open a file and want to put the contents in a string array. I tried as below.
 String[] names;
s = new Scanner(new BufferedReader(new FileReader("outfile.txt")));

while (s.hasNext()) {
                String item = s.next();
                item.trim();
                email = item;
                names = email;
            }
But I know that this is a wrong way of adding elements into my string array names []. How do I do it? Thanks.

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jun 1 2009
Added on Nov 13 2007
5 comments
7,083 views