This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes masked a String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "masked a String" Watch "masked a String" New topic
Author

masked a String

Saral Saxena
Ranch Hand

Joined: Apr 22, 2011
Posts: 202

Hi Folks,

I have a barcode LYL01016278572011000000012 , Now I want that when I print it on console ,Only last 4 numbers should be shown rest all should be XXX , say for example.. XXXXXXXXXXX1212 in the form of masked ..!!
please advise me how to achieve this..!!

I have an rough idea...



but is there any advanced functionality does new java 6 gives us, or any other way..!! please advise..!!

Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18509
    
  40

Saral Saxena wrote:Hi Folks,

I have a barcode LYL01016278572011000000012 , Now I want that when I print it on console ,Only last 4 numbers should be shown rest all should be XXX , say for example.. XXXXXXXXXXX1212 in the form of masked ..!!
please advise me how to achieve this..!!

I have an rough idea...



but is there any advanced functionality does new java 6 gives us, or any other way..!! please advise..!!



BTW, I took a shot at answering this topic, with the code from your other topic...

http://www.coderanch.com/t/572056/java/java/extracting-portion-number-string

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
jQuery in Action, 2nd edition
 
subject: masked a String
 
Similar Threads
Spitting
Generic Interface Example
The best film soundtracks I've heard ever
on null pointerexception
Masking a byte