方法一:利用java中的文件delete方法

ps:路径一定是//!!!!!!eg://tmp//linuxup//删除的文件名

 localPath = "/tmp";
            File  delfile = new File("//tmp"+good.getGpictureid().replace("linuxup","/"));
            // 路径为文件且不为空则进行删除
            System.out.println("---删除"+delfile.isFile()+delfile.exists());
            if (delfile.isFile() && delfile.exists()) {
                delfile.delete();
                System.out.println("---删除源文件成功");
            }

方法二:利用linux中的终端命令

String path = "/tmp"+gplist.get(0).getGpic().replace("linuxup","");//文件夹路径
                System.out.println("删除路径"+path);
                try{
//                    Runtime.getRuntime().exec("su *******");//用于转换权限
                    Process process = Runtime.getRuntime().exec("rm -f"+path);
                    System.out.println("删除成功");
                }catch(IOException e){
                    e.printStackTrace();
                }