Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Steven Devijver

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Format code with line numbers in Markdown notation

C:\>type Format.groovy | groovy Format
     1: def counter = 1
     2:
     3: System.in.eachLine {
     4:         line ->
     5:
     6:         def result = "    "
     7:         (2 - ("" + counter).length()).times { result += " " }
     8:         result += "${counter}: ${line}"
     9:         println result
    10:         counter++
    11: }

C:\>


def counter = 1

System.in.eachLine {
	line ->
	
	def result = "    "
	(2 - ("" + counter).length()).times { result += " " }
	result += "${counter}: ${line}"
	println result
	counter++
}

Send a bad request to a web service for testing garbage resilience

// description of your code here

def link = "http://localhost:8080/webservices/MyWebService"

def url = new URL(link)

def conn = url.openConnection()
conn.doOutput = true

conn.outputStream << "BROL"

conn.inputStream.eachLine { println it }
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS