• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

read text file with groovy and ignore specific char

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

starting to learn groovy with master resource from groovy documentation http://www.groovy-lang.org/documentation.html

i am struggling to learn on read files with groovy, is it possible to read text file in groovy, read line by line, iterate it and skip specific line (line contains specific char) or skip blank line?

appreciate any pointer or help

thanks
 
Marshal
Posts: 8857
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A warm welcome to the Ranch

Yes, it is possible to read text files in Groovy. The documentation you started with shows how to do that (I found where). But before you dive into the syntax, maybe it is worth to start with pseudo code.
Please try to define in simple steps in english or other your favorite language, what needs to be done, so everyone (especially you) could understand it (even 10 years old child). Once you're clear about the things you are needed to do, we'll look up for syntax details, so we can achieve that.

Programming first is a planning and defining clearly the steps what needs to be done. In similar way as a recipe of your favorite food. If you'd start doing things you're not sure about, probably you'd get something wrong.

In case you still wondering, how the heck files are being read in groovy:

Documentation wrote:


For more extensive and flexible ways to read the files, please go through this tutorial (<- link), so there you'll find examples where to start. Look for paragraph "3.3.1. Working with IO".
 
reply
    Bookmark Topic Watch Topic
  • New Topic