[Resolvido] Verificar existência de arquivos  XML
Índice dos Fóruns » Google Android e Java Micro Edition (ME)
Autor Mensagem
Fabiano Almeida
JavaChild

Membro desde: 24/07/2008 13:06:34
Mensagens: 120
Offline

Amigos,

Construí o método abaixo par fazer upload de determinado arquivo para o ftp.

A única coisa que preciso saber agora é como verificar se o diretório que vou pegar o está vazio.

Alguém pode me dar uma luz.

Segue o método.

This message was edited 1 time. Last update was at 23/01/2012 11:25:03


Fabiano Almeida
Analista de Sistemas
robsonoliveira
Smalltalk
[Avatar]

Membro desde: 09/01/2011 12:26:08
Mensagens: 1
Localização: Goiânia
Offline

Boa tarde



Usa um list e verifica seu retorno, se retornar null e por que o diretorio está vazio.


Robson Oliveira
[Email] [MSN]
marcelohd02
Thread.start()
[Avatar]

Membro desde: 28/08/2008 12:00:55
Mensagens: 45
Offline

http://docs.oracle.com/javase/1.5.0/docs/api/java/io/File.html

public String[] list()
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.
If this abstract pathname does not denote a directory, then this method returns null. Otherwise an array of strings is returned, one for each file or directory in the directory. Names denoting the directory itself and the directory's parent directory are not included in the result. Each string is a file name rather than a complete path.

There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.

Returns:
An array of strings naming the files and directories in the directory denoted by this abstract pathname. The array will be empty if the directory is empty. Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.
Throws:
SecurityException - If a security manager exists and its SecurityManager.checkRead(java.lang.String) method denies read access to the directory
[Email]
felipebonezi
JavaEvangelist
[Avatar]

Membro desde: 28/04/2010 12:28:06
Mensagens: 330
Localização: Recife/PE
Offline

This message was edited 1 time. Last update was at 20/01/2012 12:37:05


Felipe Bonezi
Graduando em Engenharia da Computação-POLI/UPE

Blog Android/WP7/iOS @ Debug de Códigos
-

[WWW] [MSN]
Fabiano Almeida
JavaChild

Membro desde: 24/07/2008 13:06:34
Mensagens: 120
Offline

Pessoal resolvi desta forma.





Valeu pela força.

Fabiano Almeida
Analista de Sistemas
 
Índice dos Fóruns » Google Android e Java Micro Edition (ME)
Ir para:   
Powered by JForum 2.1.8 © JForum Team