Je dois créer 4 fichiers de sortie.Création de fichiers de sortie à partir d'un tableau de chaînes
J'obtiens actuellement un seul fichier.
String url1 = "www.xxxx.com";
String url2 = "www.xxxx.com";
String url3 = "www.xxxx.com";
String url4 = "www.xxxx.com";
String tableaurl[] = {url1,url2,url3,url4};
for(String url : tableaurl)
{
String encodedString = UrlUtils.encodeAnchor(url);
System.out.format("%s\n", encodedString);
URL myURL = new URL(encodedString);
String userpass = "username" + ":" + "password";
String basicAuth = "Basic " + Base64.encode(userpass.getBytes("UTF-8"));
URLConnection myURLConnection = myURL.openConnection(proxy);
myURLConnection.setRequestProperty("Authorization", basicAuth);
myURLConnection.connect();
InputStream is = myURLConnection.getInputStream();
BufferedReader br = null;
File dir = new File(home + File.separator + "collected" + File.separator +"test");
dir.mkdirs();
File file = new File(dir + File.separator + date.getTime());
FileOutputStream fos = new FileOutputStream(file);
StringBuilder sb = new StringBuilder();
Ce code devrait déjà créer 4 fichiers marqués par 'nouveau fichier (dir + File.separator + date.getTime());' (en supposant des temps différents) –
bonjour cricket_007, merci. – baba
Ceci est la fin du code: ligne de chaîne; \t \t \t \t try { \t \t \t \t \t \t \t \t \t \t int read = 0; \t \t \t \t \t octet [] octets = nouvel octet [1024]; \t \t \t \t \t while ((read = is.read (octets)) = -1) { \t \t \t \t \t \t fos.write (octets, 0, lecture); \t \t \t \t \t \t \t // sb.append (ligne); \t \t \t \t \t} \t \t \t \t} catch (Exception e) { \t \t \t \t \t e.printStackTrace(); \t \t \t \t \t \t \t \t \t} – baba