ColdFusion class method to invoke Java

Source: Internet
Author: User

First put the Java class called into a jar package into the ColdFusion installation directory D:\ColdFusion9\lib.

Here is the call page:

<!---introduces classes that are invoked in the class--->

<cfscript>
Objfile=createobject ("Java", "java.io.File");
Objfileinstream=createobject ("Java", "Java.io.FileInputStream");
Objioutils=createobject ("Java", "org.apache.commons.io.IOUtils");
Objftpclient=createobject ("Java", "org.apache.commons.net.ftp.FTPClient");
</cfscript>

<!---my Java class is Ftptest1.java--->

<cfobject action= "Create" type= "java" class= "FtpTest1" name= "Ftpobjtest" >

<!---below is the Testupload () method in my Ftptest1.java. And I passed the parameters--->

<cfset result=ftpobjtest.testupload ("184.172.36.12", "Forus", "Qaz23sxa", "d:\\ data 2011-08-1---2011-08-31.xls" , "/bbs/communitypic", "Tangfuqiang.xls") >

<!---print out my Ftptest1.java. View Method--->

<cfdump var= "#ftpObjTest #" >

<!---print the value returned by my method--->
<cfoutput> #result #</cfoutput>--->

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.