Posted By

asteinhaus on 07/08/07


Tagged

String center gstring


Versions (?)

gString in the middle of a line


 / Published in: Groovy
 

  • *
  • Andreas writes groovy scripts! Jana corrects the mistakes! ;-) *
  • *
  1. def star = '*'
  2. def lineof80stars = star * 80
  3.  
  4. def myName = 'Andreas'
  5. def mySister = 'Jana'
  6. def gString = "$myName writes groovy scripts! $mySister corrects the mistakes! ;-)"
  7. def centerText = star + gString.center(78) + star
  8. def centerEmptyLine = star + " ".center(78) + star
  9. def newline = '\n'
  10.  
  11. print lineof80stars + newline
  12. println centerEmptyLine
  13. println centerText
  14. println centerEmptyLine
  15. print lineof80stars

Report this snippet  

You need to login to post a comment.