Created
April 3, 2014 09:05
-
-
Save quchie/9951029 to your computer and use it in GitHub Desktop.
Grails write xml file to network folder in windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jcifs.smb.* | |
import groovy.xml.MarkupBuilder | |
import org.custommonkey.xmlunit.* | |
def writer = new StringWriter() | |
def xml = new MarkupBuilder(writer) | |
xml.records() { | |
car(name:'HSV Maloo', make:'Holden', year:2006) { | |
country('Australia') | |
record(type:'speed', 'Production Pickup Truck with speed of 271kph') | |
} | |
car(name:'P50', make:'Peel', year:1962) { | |
country('Isle of Man') | |
record(type:'size', 'Smallest Street-Legal Car at 99cm wide and 59 kg in weight') | |
} | |
car(name:'Royale', make:'Bugatti', year:1931) { | |
country('France') | |
record(type:'price', 'Most Valuable Car at $15 million') | |
} | |
} | |
def ntlm = new NtlmPasswordAuthentication("", "username", "password"); //Authenticate without DOMAIN | |
SmbFile file = new SmbFile("smb://MYPC/Users/users/targetFolder"+"/quchfile.xml",ntlm); | |
SmbFileOutputStream newFile = new SmbFileOutputStream(file,true) // true = append each time write to this file | |
newFile.write(writer.toString().getBytes()) //start writing | |
newFile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment