Skip to Main Content

Java Programming

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!

BufferedReader

807605Jul 21 2006 — edited Aug 15 2007
Hey guys.

I read in a csv file which contains 2 small lines.
String line = null;
      try {
			
    	    FileReader fr = new FileReader("c:/product/products2.csv");
			BufferedReader br = new BufferedReader(fr);
			
			while( null != (line = br.readLine() ) ) {
			  System.out.print(line +"\n");
			   }
          }    
		  catch (Exception e) {
		    e.printStackTrace();
		    }
works grand, but now i want to transfer the contents of br into an array so i can split the commas in the csv file and then transfer the single words of the csv file into an individual string variable.

The thing is i cant seem to figure out how to convert br (contents of csv file) into an array. I keep getting nullpointer errors if i try and put br in string array or arraylist. Can some one please point me in right direction.
Thanks
Mark
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 12 2007
Added on Jul 21 2006
20 comments
196 views