Core code of flex:
<Mx: remoteobject id = "service" Destination = "studentservice" fault = "{failure ();}" concurrency = "single"> <br/> <mx: method Name = "wrtietofile" result = "{writefileresult (event)}"/> <br/> </MX: remoteobject> </P> <p> <mx: SCRIPT> </P> <p> <! -- [CDATA [</P> <p> private function failure (): void {<br/> alert. show ("failed to load data"); <br/>}</P> <p> Public Function writefile (): void {<br/> service. wrtietofile (_ textarea. text); <br/>}</P> <p> Public Function writefileresult (Event: resultevent): void {<br/> alert. show (event. result. tostring (); <br/>}</P> <p>] --> </P> <p> </MX: SCRIPT> </P> <p> <mx: button x = "406" Y = "176" label = "Write File" Click = "{writefile ();} "/> </P> <p> <mx: textarea x = "219" Y = "214" width = "349" Height = "160" id = "_ textarea"/> </P> <p>
Java server core code:
@ Suppresswarnings ("deprecation") <br/> Public String wrtietofile (string context) {<br/> string filepath = ""; </P> <p> try <br/> {<br/> context = new string (context. getbytes ("UTF-8"); <br/> httpservletrequest request = flexcontext. gethttprequest (); <br/> string Path = request. getrealpath ("/"); <br/> filepath = path + "workflow. XML "; <br/> filewriter fw = new filewriter (filepath); <br/> bufferedwriter BW = new bufferedwriter (FW); <br/> BW. write (context); <br/> BW. close (); <br/>}< br/> catch (exception ex) {<br/> ex. printstacktrace (); <br/>}< br/> return filepath; <br/>}< br/>
Note: encoding of character sets