Groovy 2 Cookbook
eBook - ePub

Groovy 2 Cookbook

  1. 394 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub
Book details
Book preview
Table of contents
Citations

About This Book

In Detail

Get up to speed with Groovy, a language for the Java Virtual Machine (JVM) that integrates features of both object-oriented and functional programming. This book will show you the powerful features of Groovy 2 applied to real-world scenarios and how the dynamic nature of the language makes it very simple to tackle problems that would otherwise require hours or days of research and implementation.

Groovy 2 Cookbook contains a vast number of recipes covering many facets of today's programming landscape. From language-specific topics such as closures and metaprogramming, to more advanced applications of Groovy flexibility such as DSL and testing techniques, this book gives you quick solutions to everyday problems.

The recipes in this book start from the basics of installing Groovy and running your first scripts and continue with progressively more advanced examples that will help you to take advantage of the language's amazing features.

Packed with hundreds of tried-and-true Groovy recipes, Groovy 2 Cookbook includes code segments covering many specialized APIs to work with files and collections, manipulate XML, work with REST services and JSON, create asynchronous tasks, and more. But Groovy does more than just ease traditional Java development: it brings modern programming features to the Java platform like closures, duck-typing, and metaprogramming.

In this new book, you'll find code examples that you can use in your projects right away along with a discussion about how and why the solution works. Focusing on what's useful and tricky, Groovy 2 Cookbook offers a wealth of useful code for all Java and Groovy programmers, not just advanced practitioners.

Approach

This book follows a Cookbook style and is packed with intermediate and advanced level recipes.

Who this book is for

This book is for Java developers who have an interest in discovering new ways to quickly get the job done using a new language that shares many similarities with Java. The books recipes start simple, therefore no previous Groovy experience is required to understand the code and the explanations accompanying the examples.

Frequently asked questions

Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes, you can access Groovy 2 Cookbook by Andrey Adamovich, Luciano Fiandesio in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming in Java. We have over one million books available in our catalogue for you to explore.

Information

Year
2013
ISBN
9781849519366

Groovy 2 Cookbook


Table of Contents

Groovy 2 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
The Groovy language
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Getting Started with Groovy
Introduction
Installing Groovy on Windows
Getting ready
How to do it…
There's more...
Installing Groovy on Linux and OS X
How to do it...
How it works...
There's more...
See also
Executing Groovy code from the command line
How to do it...
How it works...
There's more...
See also
Using Groovy as a command-line text file editor
How to do it...
How it works...
There's more...
See also
Using Groovy to start a server on the command line
How to do it...
See also
Running Groovy with invokedynamic support
Getting ready
How to do it...
There's more...
See also
Building Groovy from source
Getting ready
How to do it...
How it works...
Managing multiple Groovy installations on Linux
Getting ready
How to do it...
How it works...
There's more...
See also
Using groovysh to try out Groovy commands
How to do it...
How it works...
There's more...
Starting groovyConsole to execute Groovy snippets
How to do it...
There's more...
Configuring Groovy in Eclipse
Getting ready
How to do it...
How it works...
There's more...
See also
Configuring Groovy in IntelliJ IDEA
Getting ready
How to do it...
There's more...
2. Using Groovy Ecosystem
Introduction
Using Java classes from Groovy
How to do it...
How it works...
There's more...
See also
Embedding Groovy into Java
Getting ready
How to do it...
How it works...
There's more...
See also
Compiling Groovy code
Getting ready
How to do it...
How it works...
See also
Simplifying dependency management with Grape
Getting ready
How to do it...
How it works...
There's more...
See also
Integrating Groovy into the build process using Ant
Getting ready
How to do it...
How it works...
There's more...
See also
Integrating Groovy into the build process using Maven
Getting ready
How to do it...
How it works...
There's more...
See also
Integrating Groovy into the build process using Gradle
Getting ready
How to do it...
How it works...
There's more...
See also
Generating documentation for Groovy code
Getting ready
How to do it...
How it works...
There's more...
See also
Checking Groovy code's quality with CodeNarc
Getting ready
How to do it...
How it works...
There's more...
See also
3. Using Groovy Language Features
Introduction
Searching strings with regular expressions
Getting ready
How to do it...
There's more...
See also
Writing less verbose Java Beans with Groovy Beans
Getting ready
How to do it...
How it works...
There's more...
Inheriting constructors in Groovy classes
How to do it...
How it works...
Adding the cloning functionality to Groovy Beans
How to do it...
How it works...
There's more...
Defining code as data in Groovy
Getting ready
How to do it...
There's more...
Defining data structures as code in Groovy
Getting ready
How to do it...
How it works...
See also
Implementing multiple inheritance in Groovy
Getting ready
How to do it...
How it works...
There's more...
See also
Adding a functionality to the existing Java/Groovy classes
Getting ready
How to do it...
How it works...
There's more...
See also
Defining type-checking rules for dynamic code
Getting ready
How to do it...
How it works...
There's more...
Adding automatic logging to Groovy classes
How to do it...
How it works...
There's more...
See also
4. Working with Files in Groovy
Introduction
Reading from a file
Getting ready
How to do it...
How it works...
There's more...
See also
Reading a text file line by line
Getting ready
How to do it...
There's more...
See also
Processing every word in a text file
Getting ready
How to do it...
How it works...
There's more...
See also
Writing to a file
Getting ready
How to do it...
How it works...
There's more...
See also
Replacing tabs with spaces in a text file
Getting ready
How to do it...
How it works...
There's more...
See also
Filtering a text file's content
Getting ready
How to do it...
How it works...
There's more...
See also
Deleting a file or directory
Getting ready
How to do it...
How it works...
There's more...
See also
Walking through a directory recursively
Getting ready
How to do it...
How it works...
There's more...
See also
Searching for files
Getting ready
How to do it...
How it works...
There's more...
See also
Changing file attributes on Windows
Getting ready
How to do it...
How it works...
There's more...
Reading data from a ZIP file
Getting ready
How to do it...
How it works...
There's more...
See also
Reading an Excel file
Getting ready
How to do it...
How it works...
See also
Extracting data from a PDF
Getting ready
How to do it...
How it works...
There's more...
See also
5. Working with XML in Groovy
Introduction
Reading XML using XmlSlurper
Getting ready
How to do it...
How it works...
See also
Reading XML using XmlParser
How...

Table of contents

  1. Groovy 2 Cookbook