String namePlaylist = JOptionPane.showInputDialog("Enter Playlist name :");
File inPlayList = new File(namePlaylist);
String newName = JOptionPane.showInputDialog("Enter Playlist name :");//for new name
File newF = new File(newName);
inPlayList.renameTo(newF);
File x = new File(namePlaylist);
x.delete();
它将根据用户输入创建并重命名文件。但是两个文件在执行后仍然存在。我尝试使用,delete()
但它也不起作用。
String namePlaylist = JOptionPane.showInputDialog("Enter Playlist name :");
File inPlayList = new File(namePlaylist);
String newName = JOptionPane.showInputDialog("Enter new Playlist name :");
File newF = new File(newName);
inPlayList.renameTo(newF);
inPlayList = newF;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句