-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="commons-net-3.9.0" level="project" /> | ||
<orderEntry type="library" name="commons-net-3.9.0 (2)" level="project" /> | ||
</component> | ||
</module> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import org.apache.commons.net.ftp.FTPClient; | ||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
|
||
public class FTPClientJ { | ||
|
||
public static void main(String[] args) { | ||
String server = "192.168.5.118"; | ||
int port = 21; | ||
String username = "dominichann"; | ||
String password = "Hidom@123"; | ||
String localFilePath = "C:\\users\\dooli\\Downloads\\rename.bat"; | ||
String remoteDirectory = "/home/dominichann/"; | ||
|
||
FTPClient ftpClient = new FTPClient(); | ||
|
||
try { | ||
ftpClient.connect(server, port); | ||
boolean loggedIn = ftpClient.login(username, password); | ||
|
||
if (loggedIn) { | ||
System.out.println("Logged in to FTP server."); | ||
|
||
//ftpClient.enterLocalPassiveMode(); | ||
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); | ||
|
||
File localFile = new File(localFilePath); | ||
FileInputStream inputStream = new FileInputStream(localFile); | ||
|
||
boolean uploaded = ftpClient.storeFile(remoteDirectory + localFile.getName(), inputStream); | ||
inputStream.close(); | ||
|
||
if (uploaded) { | ||
System.out.println("File uploaded successfully."); | ||
} else { | ||
System.out.println("Failed to upload the file."); | ||
} | ||
|
||
ftpClient.logout(); | ||
ftpClient.disconnect(); | ||
} else { | ||
System.out.println("Failed to log in to FTP server."); | ||
} | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
This file was deleted.