Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2006
    Messaggi
    39

    [JAVA] Problema con renameTo

    Ciao a tutti, ho questo problema:

    FileWriter FW = new FileWriter(PATHW);
    FileReader FR = new FileReader(PATHR);
    BufferedWriter BR (FW)
    BufferedReader BR (FR)
    // copio parte di ciò che leggo da fw in fr

    Dopo aver chiuso i flussi sui buffer e sui file devo rinominare il file FR in FW.
    Faccio:
    File dest=new File(PATHW);
    File f=new File(PATHR);
    f.renameTo(dest) ---> questa mi torna sempre false

    Come mai?
    grazie

  2. #2
    Utente di HTML.it L'avatar di andbin
    Registrato dal
    Jan 2006
    residenza
    Italy
    Messaggi
    18,284

    Re: [JAVA] Problema con renameTo

    Originariamente inviato da zeccaman
    f.renameTo(dest) ---> questa mi torna sempre false

    Come mai?
    La documentazione di renameTo dice:

    Many aspects of the behavior of this method are inherently platform-dependent: The rename operation might not be able to move a file from one filesystem to another, it might not be atomic, and it might not succeed if a file with the destination abstract pathname already exists.

    Potrebbe forse essere questo il problema.
    Andrea, andbin.devSenior Java developerSCJP 5 (91%) • SCWCD 5 (94%)
    java.util.function Interfaces Cheat SheetJava Versions Cheat Sheet

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.