Ich habe dieses Problem, dass ich eine Datei erstellen, aber das Erstellen von leeren Datei.Erstellen Sie eine Datei von einem OutputStream
Ich benutze eine API von Dropbox, Code von Dropbox funktionieren gut, aber ich weiß nicht, dass es mir nicht gut. Ich habe 2º und 3º Codes für meine App verwendet, das funktioniert gut.
Diese arbeiten hierarchisch. Ich sende outputStream für die Funktion. Aber das ist leer.
Ich benutze outputStream, weil ich brauche, dass dies mit outputstream funktioniert.
1º-Code (Klasse-Test || Call):
File tempFile=new File("C:\\PRUEBAS_TFG\\cloud.png"); if (! tempFile.exists()) { tempFile.createNewFile(); }
File file = new File("C:\\PRUEBAS_TFG\\cloud.png");
OutputStream outputStream = new FileOutputStream(file);
catmanager.downloadFilesToItem(catmanager.getAllListCatalog().get(0), catmanager.getAllListCatalog().get(0).getItems().get(2), listFile, outputStream);
outputStream.close();
2e-Code (Klasse catmanager || 1ºbody):
public void downloadFilesToItem(Catalog catalog, Item item, List<String> files, OutputStream output){
try{
String fsPath;
fsPath = pathCatalog(catalog);
getFSManager().changeDirectoryConfigNPath(fsPath+"/"+item.getName()+"_item");
for(int i = 0;i<files.size();i++){
getFSManager().downloadFile(files.get(i), output);
}
}catch(Exception e){
e.printStackTrace();
}
}
3ºCode (Klasse FSManager || 2ºbody)
public void downloadFile(String fileName, OutputStream output) throws IOException{//Aqui deveria Buscar el Fichero Funciona por que da la casualidad que esta el fichero en la primera nube
/** Cogemos la lista de FS del usuario */
List<IFileSystem> aux = getFileSystemsUser();
for(int i = 0; i < aux.size();i++){
/** Se realiza la Funcionalidad del metodo*/
System.out.println(aux.get(i).toString());
try{
aux.get(i).downloadFile(_listPath.get(i)+"/"+fileName, output);
i = aux.size()+1;
}catch(IOException e) {
}
}
}
4ºCode (Klasse aux Dropbox || API Dropbox):
public void downloadFile(String fileName, OutputStream aux) throws IOException{
try{
getDbxClient().getFile(fileName, null, aux);
}catch(IOException e){
throw e;
}catch(DbxException u){
throw new IOException(u.getCause());
}
}
Danke Fortschritt.
Könnten Sie bitte ein minimales (und besser formatiertes) Beispiel angeben? :-) Wir würden gerne helfen. :-) –
danke für den Hinweis, ich habe den Beitrag geändert –