Deleting a file using getParameter()

<%
      File d = new File(dir);
      File[] files = d.listFiles();
      for (int i = 0; i < files.length; i++)
             filename=files.getName();
%>
<input name="delete_box" type="checkbox" value="<%=filename%>">
<%
String[] fileNames = getParameterValues("delete_box");
for (int j = 0; j < fileNames.length; j++)
String fileOne = new String(fileQ[i].toString());
for (int k = 0; k < files.length; K++)
i f (filename.equals(fileOne))
files[k].delete();
Please help! In the code above, I am trying to allow a user check a checkbox for files they want to delete. I am trying to put the checked files into a String array, then loop through the array and compare it to files stored on the hard drive, then delete the file when they are equal.
I'm not that familiar with using getParameter() and believe I am using it wrong as the code above does not delete the files. Any help would be greatly appreciated as I have been working on this for days.
thanks

The code looks ok to me - what you have shown of it.
As DrClap intimated, it would be better to split this into two parts.
One which displays the files/checkboxes (first request)
Another which handles the submission of that page (second request)
The problem I could see right now is that it would display all the current files, and then go through deleting some of them - so the ones you have displayed are now incorrect.
The best way to sort this out is to print out the values that you are retrieving - see if they are being got successfully from the form submission (I don't see a form, or submit button, but I presume they are present)
Cheers,
evnafets

Similar Messages

  • How do I delete a file using Xterminal?

    Hi , recently in the interest of playing Doom thro my N900 - I copied 3 wad files thro xterminal to opt/doom/wads..
    Now i guess this is occupying my root memory? do you know how i can delete the files using Xterminal. pls let me know
    thx.

    if it is in /opt, it shouldn't be!!
    /opt is actually linked into /home
    /home is a 2GIG partition on the EMMC that stores /opt (for optified packages.. all packages you download should sit in /opt) and all your settings / content (like address books and conversations)
    To delete it using an x terminal, you really mean using a shell.. the shell is what you see inside the x terminal..
    cd /opt/blah/dir
    rm filename
    rm is delete.. or more accurately remove!! It came in a time when keypresses were expensive
    cp is copy
    mv is move /rename
    ls is list (as in dir)
    df is diskspace free
    du is diskspace used (as in by a file or directory)
    there are loads of things like that
    be careful.. rm is the easiest way to ruin a system!

  • Deleted itouch files using ifile from cydia. i restarted it but now it shows the apple logo and that is it... it doesnt respond. any ideas of how to make it work?

    I restarted my itouch using the home button and top button...it restarted but it only shows the apple logo and that is it.  I deleted all files from ifile and then it froze... any ideas of how to make it work again?

    Discussions of hacked ipods is not permitted here.

  • Deleting PDF files using Adobe Acrobat Standard XI

    I can't delete PDF files I created myself. I get the error message I don't have access to edit, see snapshot above. I am the administrator of my own laptop. Browsing this forum helps me to locate the same query as mine but no exact answers/steps of how to bloody delete the damn files. *sorry, bit annoyed of the run-around links & not found pages* Any help would be appreciated. Thank you in advance.

    I want to just delete closed PDF files. And I know how to delete using Del button or Right Click > Delete. The problem is I get error message saying the file I want to delete, can't be deleted.
    I tried a number of combinations with Preview enabled & disabled, but still won't let me delete the files. I haven't tried exiting/closing Acrobat AFTER disabling Preview THEN deleting the PDF files, will try this. But if this is how I'm supposed to delete files in Adobe XI from now on, come on, seriously?! I work with a lot of PDF files. I shouldn't have to close down the application (Acrobat) just to delete the closed PDF files using my File Explorer view. It's like having to exit Word each time I want to delete closed .docx files.
    Will try & advise.

  • How to delete a file using checkbox!!!

    i'm developing one project using the file operations implementations. I'm displaying the contents of the file in my jsp page. The first column i've putted a checkbox option and at last i've created the button. If i clicked that particular checkbox and then if i press the delete button then it should be able to delete the all check marked files from the directories.
    Could anyone tell me how to do this in jsp. Is there any need for javascript or it can be done only through the jsp codings.
    in advance thanks....

    <html>
    <head>
    <title>Delete All Example</title>
    <script>
    function DeleteAll(){
         var answer = confirm("Do you really want to delete these selected files?")
         if (answer != 0) {
              for(var i=0; i<3; i++){
                   if( (document.form1.filecheck(i).checked == true) && (document.form1.filepath(i).value != "") ){
                        var fso = new ActiveXObject( "Scripting.FileSystemObject" );
                        fso.DeleteFile(document.form1.filepath(i).value, true);
    </script>
    <body>
    <form name="form1">
    <table border="1">
    <script>
    for(var i=0; i<3; i++){
         document.write("<tr><td><input type='checkbox' name='filecheck' value='filecheck'><br></td><td><input type='file' name='filepath'></td></tr>")
    </script>
    <tr><td colspan="2" align="center"><input type="button" name="go" value="Delete All" onClick="DeleteAll()"></td></tr>
    </table>
    </form>
    </body>
    </html>Cheers

  • Delete backup files using shell script

    Hi Gurus,
    I have to delete previous month backupfiles like sample.ttp-04-24-06 file from directory called 0424. Like that I need to delete the whole month files by using shell script.
    Please I will run this script once in a month. So it will delete all previous month's backup files which are available in the date directory of that month(0401,0402,0403 etc).
    Please help me out to solve this issue.
    Thanks in advance.

    Hi Fish,
    Its working fine. Thanks a lot for your excellent idea to solve my issue.
    Thanks again.
    bye,
    Peter.

  • RENAME/COPY/DELETE a file using FTP Adapter in 11g using dynamic values

    Hi All
    We have a requirement to do the above for a client. I was able to find a post\blog that tells you to add the below properties in FTP adapter JCA file and it works but,
    <interaction-spec className="oracle.tip.adapter.ftp.outbound.FTPIoInteractionSpec">
    <property name="SourcePhysicalDirectory" value="foo1"/>
    <property name="SourceFileName" value="bar1"/>
    <property name="TargetIsRemote" value="false"/>
    <property name="TargetPhysicalDirectory" value="foo2"/>
    <property name="TargetFileName" value="bar2"/>
    <property name="Type" value="COPY"/>
    </interaction-spec>
    The problem is that how to assign these values dynamically (from xpath or bpel variables etc). Can somebody provide me with some pointers? Its very urgent!

    Use the below approach to set the directory and file names dynamically.
    In BPEL source mode, specify the bpelx:inputProperty. Set the values for these variables in bpel. These can also be accessed as bpel preference values.
    <invoke>
    <bpelx:inputProperty name="jca.ftp.SourceFileName" variable="SourceFileNameVar"/>
    <bpelx:inputProperty name="jca.ftp.TargetFileName" variable="TargetFileNameVar"/>
    </invoke>

  • Can't delete a file on iDisk. It says it's in use.

    I cannot delete file on idisk, although I try to remove them it says items is in use, which is not...
    someone knows how to fix this?

    jakotyo wrote:
    I cannot delete file on idisk, although I try to remove them it says items is in use, which is not...
    someone knows how to fix this?
    When I've had this trouble I've always been able to delete such files using the MobileMe Web interface.

  • How to delete a file by using batch file

    hi
    i tried for deleting a file from batch filr in Linux environment.
    it is working when i run batch file thruogh command line.
    but its not woking through program.
    i am sending tha code that i used in tha program.
    First i have to create the file and send the information to that file
    and the content from taht file after that i have to delete the file.
    For that i wrote code but the batch is not woking.
    Batch file
    @echo off
    rm filename
    Actual Program Code
    I used RunServer
    public class RunServer extends Object
    RunServer();
    String cmdServer = "test.bat";
    Runtime run = Runtime.getRuntime();
    Process p = null;
    try
    p = run.exec(cmdServer);
    catch(IOException e)
    System.out.println("Error:"+e);
    By using RandomAccessFile i am creating a file
    please help me
    Thankyou

    1) You can't execute a batch without having a shell.
    2) It's totally stupid to run a one-line batch file from system.exec.
    3) It's also totally stupid to delete a file using Runtime altogether.
    But there you go...

  • Delete file using file adapter

    Hi,
    How can we delete a file using file adapter, I am using SOA 11g R3.
    Thanks
    Yatan

    thanks for reply,
    What I am trying to do is to only delete the file, is there some way where we can simply do a "delete", instead of first reading a file and then deleting it.
    Thanks
    Yatan

  • Problem in deleting Zip files unzipped using java.util.zip

    I have a static methos for unzipping a zip file. after unzipping the file when i am trying to delete that file using File.delete()its not getting deleted. but when methods like exist(). canRead(), canWrite() methods are returning true what can be the possible problem ? i had closed all the streams after unzipping operation Please go through the following code.
    public static boolean unzipZipFile(String dir_name, String zipFileName) {
    try {
    ZipFile zip = new ZipFile(zipFileName);
    Enumeration entries = zip.entries();
    while (entries.hasMoreElements()) {
    ZipEntry entry = (ZipEntry) entries.nextElement();
    // got all the zip entries here
    // now has to process all the files
    // first all directories
    // then all the files
    if (entry.isDirectory()) {
    // now the directories are created
    File buf=new File(dir_name,entry.getName());
    buf.mkdirs();
    continue;
    }// now got the dirs so process the files
    entries = zip.entries();
    while(entries.hasMoreElements()) {
    // now to process the files
    ZipEntry entry = (ZipEntry) entries.nextElement();
    if (!entry.isDirectory()){
    File buf=new File(dir_name,entry.getName());
    copyInputStream(
    zip.getInputStream(entry),
    new BufferedOutputStream(
    new FileOutputStream(buf)));}
    } catch (IOException e) {
    e.printStackTrace();
    return false;
    return true;
    now i am trying to call this method to unzip a zip file
    public static void main (String arg[]){
    unzipZipFile("C:/temp","C:/tmp.zip");
    java.io.File filer = new File("C:/tmp.zip");
    System.out.println (filer.canRead());
    System.out.println (filer.canWrite());
    System.out.println (filer.delete());
    Please tell me where my program is going wrong ?

    Thanks .. the problem is solved... i was not closing the Zip file .. rather i was trying to close all the other streams that i used for IO operaion ... thanks a lot

  • Failed to delete a file in MS Vista using java.io.File.delete()

    while trying to delete a file using java.io.File.delete(), it returns true but the file lies intact.
    i'm sure there is no handle or stream open on the file..
    the same code is running fine in XP..
    if anyone can help me.. thanks

    thanks all..
    the problem is diagnosed further..
    MS Vista does not let a user program to delete any file from 'windows' or 'program files' directories..
    Even when the file is deleted manually thru explorer a confirmation is taken from the administrator.. even when he is logged in..
    i for now have opted to install and use my program in Vista outside 'program files' directory...
    more clarification welcome..

  • Using a server side package to copy and delete flat files.

    Can anyone tell me if it is possible to copy or delete flat files using comands issued from within a PL/SQL program unit on the server. I know of the package UTL_FILE for the reading and writing of flat files.

    Malcolm,
    if you use 8i, you can create a Java class to do that for you, and call one of it's metohds from PL/SQL, see http://www.oracle.com/oramag/oracle/00-Mar/o20java.html
    null

  • N95 8GB: Problem on deleting video file

    Hi,
    Is there any body experienced this problem. When I'm trying to delete a file from Video Centre > My videos directory, I'm receiving this error... "Unable to delete. File video.mp4 is open."
    Do you have resolution for this? Tnx in advance.
    Br,
    Pete

    21-Nov-200709:06 PM
    pmpinguel wrote:
    posted my detailed steps in the n95 8gb main discussion thread. go see
    I followed your steps but I got this message.... "USB data transfer mode activated. MASS MEMORY MAY NOT BE USED DURING THIS TIME."
    Actually the video file was not there anymore in my File Mgr folder but the problem is the video file is still there in Video centre > My videos folder. When I tried to delete the file using "c" or Options > delete, the error says "Unable to delete. File video.mp4 is open."
    I also tried to reset the phone to its factory settings but still video file was there.
    I think this is a bug. Pls advice. Tnx in advance.
    Br,
    Pete

  • Help needed deleting corrupted file

    G'day,
    I have a corrupted file on my hard disk. It is a Vault backup file created by Aperture. Whenever I do anything with the file (e.g., try to unlock it, try to view info, try to open it), the o/s immediately tells me that I have to manually turn off the system (which is what I understand to be a kernel panic).
    I have tried to delete the file using the terminal window and by placing the file into a folder and moving the folder to trash. In all cases, I'm told to manually shut down the computer (even when I tried to empty the trash).
    It's a 30 gig file, so I'd like to be able to delete it in order to save the hard disk space. Does anyone have any suggestions? I'll reformat the drive if I have to, but I'd prefer to remove just the file.
    Thanks for your help.
    Regards,
    Doug

    Sometimes it happens that the Finder just doesn't want to empty the trash anymore and says "The operation cannot be completed because the item "" is in use.". That's a good warning if it is true, but sometimes you want to get rid of an application and this warning appears even though the only thing running is the Finder. Usually after a restart you can delete it. But that is very time consuming and even then, it is sometimes still stuck not wanting to be deleted. There is a risky command that can be used in the Terminal that will empty the trash no matter what. Risky because a simple error in the syntax could erase a lot of stuff that you want to keep.
    There is a much easier and quicker way of forcing the Finder to empty the trash no matter what! It is done in the freeware customization and maintenance application OnyX (download @ http://www.titanium.free.fr/pgs/english.html ). Once you loaded OnyX and entered your administrator password, choose "Cleaning" in the top bar. Click on the "Trash" tab. You can now choose whether you want to "Delete" or to "Securely Delete" (by overwriting) and click Execute. That's it, it will force the Finder to empty the trash even if the files are in use!
    Also look at these links.
    Solving Trash Problems
    http://www.thexlab.com/faqs/trash.html
    How To Fix Stubborn Trash and Why it Won't Delete
    http://www.osxfaq.com/Tutorials/LearningCenter/HowTo/Trash/index.ws
     Cheers, Tom

Maybe you are looking for

  • 2 iTM accounts on the same computer

    Hello community... I have an imac at home with several accounts on it with each their itunes settings and itunes accounts. I have installed iTM on my itunes and apple ID. My wife would like to have her own iTM as well but when we apply for it on her

  • Unable to print a publisher file from an RDP

    Hello, I get the following error when trying to print a publisher file when on an RDP. It will not print to the XPS either. I have tried administrator mode and this doesn't work and also tried restarting the RDP. This is affecting two users who have

  • Pnpce logical database

    hi, How to create report catagory using pnpce logical database? Thanks, sunil

  • Condition type 'Value' check mark

    Hi All, In Condition type definition, you have a check mark option for 'Value' (in the scetion 'Changes which can be made'). What is that for? The F1 help text says " Specifies whether the value of the condition type can be changed during document pr

  • Invalid argument error in IE7

    I'm working on my first HTML5 site. And I'm getting an invalid argument error that's keeping it from loading all of the content on the page. It's telling me that the error is in line 256, but line 256 is an image tag. The page in question is here: ht