Recommendation-Java remote file docking technology (1/2)

Source: Internet
Author: User

# Src/dao. properties
# Key-value pair information is saved here
# Interface name (no packgage) = implementation class
# Note:
# A: [path symbol] [must] is [/] [such as: D:/home/publish]
# B: [key = value] to [next] [do not allow spaces] [for example: REMOTE_HOST_IP = 172.77.9.77]
# REMOTE_HOST_IP remote machine IP address
# LOGIN_ACCOUNT remote machine login name
# LOGIN_PASSWORD: remote machine logon password
# SHARE_DOC_NAME remote machine shared folder name (read and write permissions must be granted after sharing is set)
# SourcePath local path
# TargetPath target path (actual path = shared folder path + target path)
REMOTE_HOST_IP = 172.77.9.77
LOGIN_ACCOUNT = 77
LOGIN_PASSWORD = 77
Pai_doc_name = vfs_home
SourcePath = D:/home/publish
TargetPath = publish
2. Import jar package: jcifs-1.3.16.jar

 

3. Read the value class corresponding to the key in the configuration file: RemoteConfigUtil. java

The code is as follows: Copy code

Package com. remote;

Import java. io. IOException;
Import java. util. Properties;

/**
* Read the value corresponding to the key in the configuration file.
* @ Author JunjieQin
*/
Public class RemoteConfigUtil {
Private String REMOTE_HOST_IP;
Private String LOGIN_ACCOUNT;
Private String LOGIN_PASSWORD;
Private String pai_doc_name;
Private String sourcePath;
Private String targetPath;

// Construction method without parameters
Public RemoteConfigUtil (){
Try {
// Read the configuration file
Properties prop = new Properties ();
Prop. load (this. getClass (). getClassLoader (). getResourceAsStream ("copyRemoteFile. properties "));
// Obtain value based on key
REMOTE_HOST_IP = prop. getProperty ("REMOTE_HOST_IP ");
LOGIN_ACCOUNT = prop. getProperty ("LOGIN_ACCOUNT ");
LOGIN_PASSWORD = prop. getProperty ("LOGIN_PASSWORD ");
Pai_doc_name = prop. getProperty ("pai_doc_name ");
SourcePath = prop. getProperty ("sourcePath ");
TargetPath = prop. getProperty ("targetPath ");
} Catch (IOException e ){
E. printStackTrace ();
  }
 }
Public String getLOGIN_ACCOUNT (){
Return LOGIN_ACCOUNT;
 }

Public void setLOGIN_ACCOUNT (String login_account ){
LOGIN_ACCOUNT = login_account;
 }

Public String getLOGIN_PASSWORD (){
Return LOGIN_PASSWORD;
 }

Public void setLOGIN_PASSWORD (String login_password ){
LOGIN_PASSWORD = login_password;
 }

Public String getREMOTE_HOST_IP (){
Return REMOTE_HOST_IP;
 }

Public void setREMOTE_HOST_IP (String remote_host_ip ){
REMOTE_HOST_IP = remote_host_ip;
 }

Public String getSHARE_DOC_NAME (){
Return pai_doc_name;
 }

Public void setSHARE_DOC_NAME (String pai_doc_name ){
Pai_doc_name = pai_doc_name;
 }

Public String getSourcePath (){
Return sourcePath;
 }

Public void setSourcePath (String sourcePath ){
This. sourcePath = sourcePath;
 }

Public String getTargetPath (){
Return targetPath;
 }

Public void setTargetPath (String targetPath ){
This.tar getPath = targetPath;
 }
}


Homepage 1 2 Last page

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.