Como Criar um arquivo txt em tempo de execução

2 respostas
Volrath

estou tentando criar um arquivo txt em tempo de execução …como eu faço isso?, verificar se o arquivo existe, ler , escrever ja fiz tudo… mais criar que é bom nada.

Vlw

2 Respostas

rodrigo_gomes

Olá,

Se vc fizer

FileWriter writer = new FileWriter("teste.txt");
PrintWriter saida = new PrintWriter(writer);
saida.println("Ola Arquivo!");
saida.close();
writer.close();

um arquivo teste.txt já será criado.

da uma olhadinha nesse tutorial, pode te ajudar (foid e lah que tirei esse exemplo):
http://www.guj.com.br/java.tutorial.artigo.13.1.guj
[]´s
Rodrigo

sapulha

Se estiver usando File, tente:

File file = new Flie(caminho/arquivo.txt);

if(!file.exists())

file.createNewFile();
Criado 16 de novembro de 2006
Ultima resposta 16 de nov. de 2006
Respostas 2
Participantes 3