Metoda z File --file.renameto(File dist) zwraca false.
Pracuje pod linuxem Ubuntu. Nie wiem czy to nie problem systemowy, znaczy czy mój program po prostu nie ma uprawnień
do zmiany nazwy pliku .
Zmieniałem już wszelkie ustawienia pliku.ods z poziomu terminalu ale to też nie pomogło.
Ta metoda to tylko jedna z wielu sposobów jakie już testowałem i wygrzebałem z netu ,ale wszystkie rozbiły się o ten problem.
kod metody :
Code: Zaznacz cały
private void zmienODSnaZip() throws IOException
{
File przyslany= new File(this.filePrzyslany.getName());
System.out.println(przyslany.canWrite());
int dotPos = filePrzyslany.getName().lastIndexOf ( "." ) ;
String strExtension = filePrzyslany.getName().substring ( dotPos + 1 ) ;
String strFilename = filePrzyslany.getName().substring ( 0 , dotPos ) ;
String newfileExtension = "zip" ;
String strNewFileName = strFilename + "." + newfileExtension;
File newfile = new File ( strNewFileName ) ;
boolean Rename = przyslany.renameTo ( newfile ) ;
if ( !Rename )
{
System.out.println ( "nieudane" ) ;
}
else
{
System.out.println ( "udane" ) ;
}
}
Z poziomu systemu to łatwe zmieniam tylko ods na zip i mogę już rozpakować archiwum .
A jak do tego dobrać się z poziomu kodu javy ?