• Post Reply Bookmark Topic Watch Topic
  • New Topic

Tokenizer  RSS feed

 
sachin ramesh
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am new to java, i got some set of text in a file. i need to read those text and display in such a way that each line should contain only 20 characters. i.e., After reading all those text when wirting in a browser it should display only 20 characters in a line. how this can be done in tokenizer or any other option is there. Pls give me some sample coding, thank you

Balen
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello "sachin sachin"-

Welcome to JavaRanch.

On your way in you may have missed that JavaRanch has a policy on display names, and yours does not comply with it - please adjust it accordingly, which you can do right here. Thanks for your prompt attention to this matter.

As to your question, I don't think you need a tokenizer. Check out the "substring" methods of the String class. They allow you extract specific portions of a string (e.g. the 21st to 40th character). Just make sure that the "end" index is not beyond the length of your line.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!