java - Printing an ArrayList of Strings to a PrintWriter with word wrap -


some classmates , working on homework assignment java requires print arraylist of strings printwriter using word wrap, none of output passes 80 characters. we've extensively googled , can't find java api based way this.

i know it's "wrong" ask homework question on so, we're looking recommendations of best way this, or if missed in api. isn't major part of homework, small output requirement.

ideally, i'd able wordwrap arraylist's tostring since it's nicely formatted already.

well, first me, it's first time 1 of students has posted question 1 of projects i've assigned them. way phrased, looking algorithm, , answers you've shared fine me. however, typical case of trying make things complicated. part of spec not mentioned 80 characters limit not hard limit. said each line of output file had 80 characters long. ok go on 80 little. in version of solution, had running count , did modulus of count add line end. varied value of modulus until output file looked right. resulted in lines small numbers being short used different modulus when numbers small. wasn't big part of project , it's interesting got attention.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -