السلام عيكم ......
فضلا وليس امرا اخواني المبرمجين
اريد ان انقل ملفات من حاسبة الى اخرى ضمن شبكة محلية لاتحتوي على الانترنيت
علما انه كل حاسبة لديه ايبي واسم مستخدم وكلمة مرور
ووجدت هذه الكود
public static void getDataFiles( String server,String username,String password,
String folder,String destinationFolder ){
try
{
// Connect and logon to FTP Server
FTPClient ftp = new FTPClient();
ftp.connect(server);
ftp.login(username, password);
System.out.println("Connected to " + server + ".");
System.out.print(ftp.getReplyString());
// List the files in the directory
ftp.changeWorkingDirectory( folder );
FTPFile[] files = ftp.listFiles();
System.out.println( "Number of files in dir: " + files.length );
DateFormat df = DateFormat.getDateInstance( DateFormat.SHORT );
for( int i=0; i<files.length; i++ )
{
Date fileDate = files[ i ].getTimestamp().getTime();
// Download a file from the FTP Server
System.out.print( df.format( files[ i ].getTimestamp().getTime() ) );
System.out.println( "\t" + files[ i ].getName() );
File file = new File( destinationFolder +
File.separator + files[ i ].getName() );
FileOutputStream fos = new FileOutputStream( file );
ftp.retrieveFile( files[ i ].getName(), fos );
fos.close();
file.setLastModified( fileDate.getTime() );
}
// Logout from the FTP Server and disconnect
ftp.logout();
ftp.disconnect();
}
catch( Exception e )
{
e.printStackTrace();
}
}لكن لم تفلح
ولكم جزيل الشكر والثواب
وشكرا
تحياتي
