Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
Groovy
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<p>Groovy는 입출력을 위한 여러가지 <table class="wysiwyg-macro" data-macro-name="unmigrated-inline-wiki-markup" data-macro-parameters="atlassian-macro-output-type=BLOCK" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e3VubWlncmF0ZWQtaW5saW5lLXdpa2ktbWFya3VwOmF0bGFzc2lhbi1tYWNyby1vdXRwdXQtdHlwZT1CTE9DS30&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>{link:지원 메서드|http://groovy.codehaus.org/groovy-jdk.html}{link}</pre></td></tr></table> 를 제공합니다. 모든 지원 메서드들은 표준 자바 라이브러리의 Reader/Writer, InputStream/OutputStream, File, URL 클래스를 사용합니다. 클로저를 사용하게 되면 예외가 발생하더라도 자원이 적절히 닫히게(closed) 됩니다. 예를 들어 파일의 각 행에 대해 반복적으로 코드를 수행하려면 다음과 같이 합니다:</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> new File("foo.txt").eachLine { line -> println(line) } </pre></td></tr></table> <p>어떠한 이유에서건 <em>doSomething()</em> 메서드가 예외를 던지면 <em>eachLine()</em> 메서드는 파일 자원을 닫아줍니다. 파일을 읽는 중에 예외가 발생해도 물론 자원이 제대로 닫힙니다.</p> <p>Reader/Writer 혹은 InputStream/OutputStream을 사용하고자 한다면 클로저를 통해 접근할 수 있는 방법이 제공됩니다. 이 경우에도 물론 자원이 제대로 해제됩니다:</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> new File("foo.txt").withReader { reader -> while (true) { def line = reader.readLine() } } </pre></td></tr></table> <h2>프로세스 사용하기</h2> <p>Groovy는 명령행 프로세스를 실행하기 위한 간단한 방법을 제공합니다:</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> def process = "ls -l".execute() println "Found text ${process.text}" </pre></td></tr></table> <p>위 표현은 java.lang.Process 인스턴스를 반환하는데, 인스턴스는 in/out/err 스트림, 종료 코드(exit value) 등을 포함하고 있습니다:</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> def process = "ls -l".execute() process.in.eachLine { line -> println line } </pre></td></tr></table>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced