@ Overridepublic void exportfujian_actioninclumed (actionevent e) throws exception {If (null = editdata | null = editdata. GETID () {msgbox. showinfo ("Save the document first"); sysutil. abort () ;}string Path = getpath (); If (null = path) {msgbox. showinfo ("select the path of the file to be saved"); sysutil. abort ();} exportattachment (editdata. GETID (). tostring (), PATH);}/*** obtain the path of the file to be saved * @ return * @ throws exception */private string getpath () throws exceptio N {string dir = ""; // default path component parent = NULL; // jfilechooser chooser = new jfilechooser (DIR); javax. swing. filechooser. filefilter dirfilter = new javax. swing. filechooser. filefilter () {public Boolean accept (file F) {return F. isdirectory () ;}public string getdescription () {return "" ;}}; chooser. setfilefilter (dirfilter); chooser. setfileselectionmode (jfilechooser. save_dialog); If (chooser. sh Owopendialog (parent) = jfilechooser. approve_option) {dir = chooser. getselectedfile (). getabsolutepath (); Return dir;} return NULL ;} /*** one-click Export of related attachments to this document * @ Param ID * @ Param path the path of the file to be exported * @ throws exception */public static void exportattachment (string ID, string path) throws exception {stringbuffer sb = new stringbuffer (); sb. append ("/* dialect */"); sb. append ("select attachment. fname_l2 name ,"); SB. append ("attachment. fsimplename type, "); sb. append ("attachment. ffile contens "); sb. append ("from t_bas_attachment attachment,"); sb. append ("t_bas_boattchasso Temp"); sb. append ("where attachment. FID = temp. fattachmentid "); sb. append ("and attachment. ffile is not null "); sb. append ("and temp. fboid = '"). append (ID ). append ("'"); irowset rs = datautils. clientexecutesql (sb. tostring (); While (RS. next () {strin G filename = Rs. getstring ("name"); string types = Rs. getstring ("type"); string fullname = path + "/" + filename + ". "+ types; file F = new file (fullname); int I = 0; while (F. exists () {fullname = path + "/" + filename + "(" + (++ I) + "). "+ types; F = new file (fullname);} blob contends = Rs. getblob ("contens"); inputstream in = contends. getbinarystream (); fileoutputstream Fos = new fileoutputstream (fullname); storeattch (FOS, In) ;}}/*** extract the BL from the database The ob object is stored in the application directory. Through. getbinarystream () method to obtain the binary input stream * @ Param ops byte output stream * @ Param IPS byte input stream */public static void storeattch (outputstream ops, inputstream IPS) {bufferedinputstream Bis = new bufferedinputstream (IPS); bufferedoutputstream Bos = new bufferedoutputstream (OPS); byte [] Buf = new byte [1024*600]; int Len = 0; try {While (LEN = bis. read (BUF ))! =-1) {Bos. write (BUF, 0, Len) ;}} catch (ioexception e) {system. out. println ("stream file writing and output exceptions" + Ips + OPS); E. printstacktrace ();} finally {If (Bis! = NULL) {try {bis. close ();} catch (ioexception e) {system. out. println ("failed to close the input stream file" + IPS); E. printstacktrace () ;}} if (Bos! = NULL) {try {Bos. close ();} catch (ioexception e) {system. out. println ("An error occurred while closing the output stream file" + OPS); E. printstacktrace ();}}}}