SORU
21 Temmuz 2009, Salı


Java kullanarak bir dosyayı yeniden adlandırma

Bir dosya test1.txt test.txt say yeniden adlandırabilir miyiz ?

test1.txt var adlandırır ?

Nasıl test.txt yeni içeriği daha sonra kullanmak üzere eklenir yani zaten mevcut test1.txt dosyaya yeniden adlandırırım?

CEVAP
21 Temmuz 2009, Salı


http://exampledepot.8waytrips.com/egs/java.io/RenameFile.html kopyalanmış

// File (or directory) with old name
File file = new File("oldname");

// File (or directory) with new name
File file2 = new File("newname");

if (file2.exists())
   throw new java.io.IOException("file exists");

// Rename file (or directory)
boolean success = file.renameTo(file2);

if (!success) {
   // File was not successfully renamed
}

Yeni dosya eklemek için:

java.io.FileWriter out= new java.io.FileWriter(file2, true /*append=yes*/);

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • CasinoRoyaleMovie's channel

    CasinoRoyale

    1 AĞUSTOS 2006
  • TastyTuts | Creative video tutorials by Gareth David

    TastyTuts |

    6 Temmuz 2011
  • Visual Life

    Visual Life

    3 Temmuz 2006