|
Groovy example source code file (FileReaderTest.groovy)
The Groovy FileReaderTest.groovy source codepackage org.codehaus.groovy.control.io class FileReaderTest extends GroovyTestCase { void testFileBOM() { def file = File.createTempFile("encoding", ".groovy") file.deleteOnExit() def fos = new FileOutputStream(file) // first write the byteorder mark for UTF-8 fos.write(0xEF) fos.write(0xBB) fos.write(0xFF) fos.write("return 1".getBytes("US-ASCII")) fos.flush() fos.close() def gcl = new GroovyClassLoader() gcl.config.sourceEncoding = "UTF-8" def clazz = gcl.parseClass(file) def result = clazz.newInstance().run() assert result == 1 } } Other Groovy examples (source code examples)Here is a short list of links related to this Groovy FileReaderTest.groovy source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.