Bedankt voor de reacties, ik ben redelijk klaar met de onbekende handelingen, ik moet er toch maar een keer echt vanaf het begin aan beginnen, echter heb ik nog wel steeds een stukje software nodig wat een bestand kan plaatsen:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
| /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package shopleasing;
/**
*
* @author Gebruiker
*/
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
public class ShopLeasing {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
// ftp://tom:secret@www.myserver.com/project/2012/Project.zip;type=i
String ftpUrl = "ftp://-----:--------@------------------------------/Toevoeging;type=1";
String host = "83.173.---.--";
String user = "b--------";
String pass = "d-------";
String filePath = "C:\\org.rar";
String uploadPath = "/org.rar";
ftpUrl = String.format(ftpUrl, user, pass, host, uploadPath);
System.out.println("Upload URL: " + ftpUrl);
try {
URL url = new URL(ftpUrl);
URLConnection conn = url.openConnection();
OutputStream outputStream = conn.getOutputStream();
FileInputStream inputStream = new FileInputStream(filePath);
byte[] buffer = new byte[BUFFER_SIZE];
int bytesRead = -1;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
inputStream.close();
outputStream.close();
System.out.println("File uploaded");
} catch (IOException ex) {
ex.printStackTrace();
}
}
} |
Na wat onderzoek ben ik hier mee gekomen, er wordt verbinding gemaakt, en ingelogd.
byte[] buffer = new byte[BUFFER_SIZE];
Geeft een probleem, iemand enig idee ?
EDIT: excuus ik dacht dat BUFFER_SIZE een constante was...moest een integer zijn (1024)
Upload URL: ftp://gebruiker-wachtwoord@website/Toevoeging;type=1
File uploaded
BUILD SUCCESSFUL (total time: 1 second)
[
Voor 5% gewijzigd door
Bas112 op 18-05-2016 16:27
]