FileFilter for executable files

I'm trying to make a FileFilter that only accepts executable files and directories. My attempt is shown below:
    public boolean accept(File f)
        if(f.isDirectory())
            return true;
        SecurityManager sm = new SecurityManager();
        try
            System.out.println(f.getPath());
            sm.checkExec(f.getPath());
        } catch (SecurityException e) {
            return false;
        return true;
    }This isn't returning anything but directories. It also strikes me as odd that the SecurityManager works by throwing exceptions, when it isn't really exceptional to have a file not be executable.
Any help here would be appreciated.

I wanted something that would work on any system. I figured that this functionality should exist simply because it is useful. As for the argument that it is too OS specific, I disagree. Every developed OS has some means for determining if a file is an executable program. Just as the Graphics package is supported on multiple systems despite different implementations, I believe that filetype identification could be done in the JREs.
But it looks like it isn't done. That appears to be the answer to my question.

Similar Messages

  • What pattern is followed when using FileFilter for filtering files ?

    Hi All,
    FileFilter is used to filter files according to the condition specified.
    for example the code is
    FileFilter fileFilter = new FileFilter(){
    public boolean accept(File inFile) {
    // To return whether it is a file
    return inFile.isFile();
    // To return whether it ends with any extension.
    // for example ends with .txt
    // return inName.endsWith("txt");
    File[] files = file.listFiles(fileFilter);
    Here FileFilter is an interface.File is a class. What pattern is followed in this operation ? does it follows - similar to any design pattern in Java ? this implementation is similar to adding an ActionListener(like an Inner Class) to a button.
    for example
    Button.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    Thanks,
    J.Kathir

    I am using a FileFilter with the following extension "*.doc". The
    getDescription() method for that extension returns "Microsoft Word
    Document", which is what gets displayed in the "Files of Type"
    dropdown. My problem is that if the user enter a wildcard (*) in the
    "File Name" field and hit enter, it changes the "Files of Type" drop
    down to that as well.
    How do you prevent the "Files of Type" selection from changing when
    using wildcard?

  • Text Message: Unable to execute file for security ...

    Whenever I'm viewing a text message, when I try to open up the "Options" menu, I see the above message, "Text Message: Unable to execute file for security reasons". This doesn't seem to impact the functionality of the menu at all, everything seems to work.
    Anyone ever come across this before?
    I've updated the phone (Nokia E66) to the latest software, and I've only got one application installed other than the default base install (Google calendar sync utility), removing that doesn't change the problem.
    Thanks in advance!

    I get the same error after SW update to latest version when I try to run some apps 

  • How to create a password file for executing psadmin command to deploy portl

    how to create a password file for executing psadmin command to deploy portlet

    What you have done is perfectly right. The password file doesn't have anything else apart from the password
    for example in your case
    $echo password > /tmp/password.txt
    However I remember that in windows install, the Application server used to wait for a user's input when a deploy was to be done for the first time. So Can you read the Release notes or the Readme file which has come with windows.
    The solution was,
    manually use asadmin command of application server to deploy some war (any webapp will do), at this time, a question will be prompted to accept a certificate. once this is done, deploy portlet should work fine!!!
    HTH

  • Keeps asking for rpt file when executing store procedure

    Hi all,
      I have coded an standard stored procedure but when I execute it, Management Studio keeps asking for .rpt file to save the results. I am using Enterprise 2008 R2. 
    This is the code:
    USE [mydatabase]
    GO
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[usp_chart](
    @parameters)
    AS
    BEGIN
     SET NOCOUNT ON;    
     DECLARE @query NVARCHAR(4000)
        DECLARE @total INT
        DECLARE @strDescriptor NVARCHAR(4000)
        DECLARE @dsvalues NVARCHAR(4000)
        DECLARE @strCache NVARCHAR(2000)
        SET @strDescriptor = dbo.udf_chart_derived_descriptor_intotemp(@derivation_Id)
     SET @dsvalues =  dbo.udf_chart_derived_dynamic_query_fortopn(  @derivation_Id,
           @cache_Id,
           @topn,
          @flt_customer_Id,
          @flt_user_Id,
          @flt_datefrom,
          @flt_dateto,
          @product_Id
        SET @strCache = 'SELECT top ' + @topn + 'PERCENT g.Supplier_Id Supplier_Id 
    INTO #T_CacheTopN
    FROM T_CacheSupp g 
    WHERE g.Cache_Id = ' + @cache_Id + 
    ' ORDER BY g.Position'
        IF @strFilter is null 
         BEGIN
    SET @query = @strCache + ';' + @strDescriptor + ';' +
    'DECLARE @total INT;' +
    @dsvalues +
    'SELECT @total = COUNT(*)
     FROM #T_Condition; 
     SELECT c.Condition_Index, ROUND(COUNT(*)/CAST(@total as float),2)*100
     FROM #T_Condition c
     GROUP BY c.Condition_Index';
         END
        ELSE
         BEGIN
           DECLARE @sqlfilter NVARCHAR(2000)
      SET @sqlfilter =  dbo.udf_chart_dynamic_query_filter_fortopn(@strFilter,@product_Id,@topn, @cache_Id)
      SET @query = @strCache + ';' +@strDescriptor + ';' +
    'DECLARE @total INT;' +
    @dsvalues +
    'SELECT @total = COUNT(*)
     FROM #T_Condition;'+ @sqlfilter +
     ';SELECT c.Condition_Index, ROUND(COUNT(*)/CAST(@total as float),2)*100 
     FROM #T_Condition c LEFT OUTER JOIN #T_NotWanted d
     ON c.Data_Id = d.Data_ID
     WHERE d.Data_Id is null
     GROUP BY c.Condition_Index';
         END 
        EXEC(@query)
        RETURN
    END
    When I execute:
    DECLARE
    @parameters NVARCHAR(4000)
    execute usp_chart_derived_fortopn @parameters
    it asks me for a .rpt file.
    Why is that? I am not running a report.
    Thanks

    As other have said, you have set Results to File.
    But since you posted your code, I had a look at it. I was not able to understand why you use dynamic SQL. For instance, this:
        SET @strCache = 'SELECT top ' + @topn + 'PERCENT g.Supplier_Id Supplier_Id 
    INTO #T_CacheTopN
    FROM T_CacheSupp g 
    WHERE g.Cache_Id = ' + @cache_Id +  ' ORDER BY g.Position'
    Can be written as
    SELECT top (@topn) PERCENT g.Supplier_Id Supplier_Id 
    INTO #T_CacheTopN
    FROM T_CacheSupp g 
    WHERE g.Cache_Id = @cache_Id  
    ORDER BY g.Position
    If you can avoid dynamic SQL, your code becomes easier to maintain, and less vulnerable for nasty surprises.
    And if you use dynamic SQL, you should use sp_executesql and pass parameter values as parameters instead of inlining them.
    Erland Sommarskog, SQL Server MVP, [email protected]
    Links for SQL Server Books Online:
    SQL 2008, SQL 2005 and 
    SQL 2000.
    (Just click the link you need.)

  • Wait for a file and start execute a scenario process

    What is the best way to achive: Wait for a file and then once the file in droped...execute a scenario process.
    Sample scenario:
    - Admin user ftp the file to a target directory on Unix (export/home/odi/input/files)
    - A scheduled scenario package will be running/scheduled daily
    - In the above scenario, The first step is to have one OdiFileWait (with options: Dir:/export/home/odi/input/files, File: xxxxx.txt,wait time and loop over..etc)
    /* But for some reason OdiFileWait is not waiting/checking for the file presence define in the option. It seems to run immediately without checking the presence of the file and passing it to run the second step) */
    - The second step is the "OdiStartScen" (This will run an interface generated scenario) and since the file doesn't exist as a source to load that this interface uses...its fails.
    What's the common practice to accomplish this? Appreciate your feedbacks…
    Thank you

    Update:
    I increased the timeout and Pollint setting in OdiFileWait option and its working fine now.
    When the file exists (or) ftp within the timeout the process goes to next step (OK). But, say the file doesn't exists and the timeout finished...how do i set a KO to OdiFileWait and stop/complete by existing at that step itself with out failure.

  • File.execute() not working for bat file

    Dear all,
    The purpose of my function copyToWinClipboard (text) is to get a string directly into the Windows Clipboard. The purpose is to allow the user of my project just to paste into the open-dialog of the application EndNote. I’m not certain whether the FM clipboard (supported by the copy/cut/paste methods for Doc) really fills into the Windows Clipboard also.
    In the PhotoShop script forum I found the idea how to do this.
    #target framemaker
    // note the blank in the path
    copyToWinClipboard ("E:\\_DDDprojects\\FM+EN escript\\FM-11-testfiles\\BibFM-collected.rtf");
    function copyToWinClipboard (text) {
      var theCmd, clipFile = new File(Folder.temp + "\\ClipBoardW.bat");
      clipFile.open('w');
    //  theCmd = "echo \"" + text + "\" | clip"; // this doesn’t help either
      theCmd = "echo " + text + " | clip";
      clipFile.writeln (theCmd);
      clipFile.close ();
      clipFile.execute ();
    Running this script provides a short flicker (the command prompt), but the clipboard does not contain the expected string. However, when double clicking on the generated I:\!_temp\ClipBoardW.bat the clipboard is filled correctly.
    IMHO the execute method does not work correctly for bat files. In another area of my project-script i run an exe file with this method correctly.

    Hi Klaus,
    sorry for my late response.
    execute definitely works witch batch-files
    Here's a "batch" - example you can test.
    There are two methods to prevent window from closing:
    "|more" - kind of pagebreak
    "pause"
    var oTemp = app.UserSettingsDir + "\\tmp";
        var MyDosCommand = "ipconfig.exe /a|more";
        var MyPath = new Folder (oTemp);
        if (!oTemp.exists)
            var MyPath = new Folder (oTemp);
            var lFehler = MyPath.create();
        oTemp = oTemp + "\\" +"nw.bat";
        var MyFile = new File (oTemp);
             MyFile.open ('w');
               if (MyFile.error > "")
                    alert("ERROR");
            MyFile.writeln(MyDosCommand);
            MyFile.writeln("pause");
            MyFile.close();
            MyFile.execute();

  • How to Create Executable file for a project for Crio Platform

    hi,
    i am using CRIO 9014  platform  for my application development.
    i am controlling (   Reset  &  then Run )  FPGA   from RT application .
    Through TCP/IP  communication the  Acquired data  (   from FPGA  then followed by some Computation Logic in RT )   is sending   to HOST computer .
    during the above process  
    First i am starting the RT Application    (  the TCP  network will be continuously in listen mode )    then
     i am  starting my HOST Application   in the project .
     here i want  to build my complete project as an  executable file 
    so that i no need to start  RT Application first and then HOST Application.
    Could you please send me One sample Project           with built in simple  ADC Acquisition  loop /  logic  in FPGA  ,  then  one sample logic  / while loop   in RT   to   acquire  this ADC data from FPGA and  send to HOST    via  TCP/IP network then   the  HOST   with GUI    for  Display in the HOST .
    This  complete project should be build in  .exe  file .
    Please  complete project  files  and .exe file    as a  zip file.
    Regards,
    Venkat

    Hi,
    I might be confused but what I understand from what you have mentioned is that you want to create a project having two VI's. One running on your FPGA target and another running on you host computer.You want to build a single executable file to complete the entire operation.
    Unfortunately you cannot have both VI's in same executable file. You can build one executable file and deploy on your FPGA target that will start running as soon as the target is booted. And you can create another executable file for running VI on your host computer. And instead of using TCP to transfer data, you could use "Interface FPGA" from FPGA module to communicate between your host computer and communicate.

  • Executable file for IMAQ VIs

    Hi friends,
                     I am back here after a long gap. Now I am again in full time research and using LabVIEW as the programing platform as usual.
    I am working on image processing and have designed a code recently for a small image analysis purpose. Several IMAQ VIs are used in my progeam. Now I want to make an executable file of it. But the file I able to build is not working in other machines having no labview because of run-time engine unavailability.
    I haave attached the screenshot of the error massage. Can anyone please help me to solve the problem?
    Thanking you all ...
    Solved!
    Go to Solution.
    Attachments:
    labview IMAQ error.png ‏193 KB

    I tried to create installer of Vision runtime engine and IMAQ but it did not worked.
    As per your information, no executable file can be run in other computer  if the program includes any IMAQ VI. Confusing. is Vision library not for programmers doing work for professional use of the program?
    I believe there must be some way which will help us to create a .exe file of a program containing IMAQ VIs. Please let me know that way, so that my .exe file can be used by anyone without hassle.
    If any kind of payment for any license or so, please let me know that too.
    RavensFan wrote:
    The dialog seems pretty self explanatory.  You need to install the run time engine.
    Did you install the LabVIEW run-time engine on the other PC's?
    Since you are using IMAQ, I believe you will also need to install the Vision Run-time engine.  The only catch there is that you can't freely distribute that one.  I believe each Vision runtime license needs to be paid for.

  • Execute file for Windows2000 on the latest CVI

    Dear experts,
    Now I have developed CVI code and built a execute file on CVI2010. And I want to run it on old-Windows2000 PC. But unfortunately it failed as
    Error Code: -114
    The format of the file is newer than this version of CVI
    I installed CVI-Runtime engine 9.01 on Windows2000, because I couldn't install the latest Runtime 2012 on Windows2000.
    In this case, what can I do? I have been checking Build and setting options on the CVI2010 for backward building option, but I have not found such a part.

    CVI does not officially support running programs against a version of the runtime that is older than the version of the ADE that you used to build it. But, given that you got as far as you did, it might actually work for you.
    The -114 error that you ran into is actually pretty easy to fix. I'm assuming that it's the LoadPanel function that is returning this error, is that right? If so, then all you should need to do is to save your .uir file in 2009 format. You can do that directly in CVI 2010, by selecting File>>Save As in the user interface editor and changing the "save as type" control.
    Luis

  • Converting Unix Executable Files for use in DVD Studio Pro

    I have several projects that were created in iDVD 2 back in 2002. In Finder, the file kind is listed as Unix Executable Files. If I add the extension .dvdproj using Get Info and try to open them in DVD Studio Pro, I get the error Wrong File Format and it will not open the project.
    The machine I am currently using does not have iDVD on it.
    Does anyone have a recommendation on a way to make these files usable for DVD Studio Pro? I understand if it is not possible.

    You can import iDVD project into DVD Studio Pro, however I think it won't work with projects from iDVD 5. I'm not sure about iDVD 2. Also these files have no extension and are listed as Unix Executable Files.

  • Shell executable file for Mac OS

    Hi ,
    Can you translate the batch file of windows in corresponding shell executable file for mac?
    The batch file actally conaints following statements:
    REM Launch script
    "C:\j2sdk1.4.0\bin\java.exe" -server -Xmx128M -DdaffodilDB_home=C:\DaffodilDB2_3\databases -cp "C:\DaffodilDB2_3\lib\DaffodilDB_Common.jar;C:\DaffodilDB2_3\lib\DaffodilDB_Server.jar" com.daffodilwoods.rmi.DaffodilDBServer "start" %1 %2 %3 %4 %5 %6 %7 %8 %9
    Thanks
    Ashish

    Thanks for your reply, but is it not seems to be the shell file for Linux or Unix? will it work in Mac system also? what would be the name of file where I save these lines?
    Thanks again

  • Software Metering not working "No usage will be tracked for process 4532, as failed to get owner info or executable file name 80004005"

    Hello,
    I'm getting the following error message in mtrmgr.log file. I have create simple visio.exe. I have removed the policy and re-added with no luck.
    mtrmgr.log file errors:
    Creation event received for process 3128 mtrmgr 3/4/2015 6:59:49 PM 952 (0x03B8)
    Unable to collect process information as process has terminated mtrmgr 3/4/2015 6:59:49 PM 952 (0x03B8)
    No usage will be tracked for process 3128, as failed to get owner info or executable file name 80004005 mtrmgr 3/4/2015 6:59:49 PM 952 (0x03B8)
    Termination event received for process 3128 mtrmgr 3/4/2015 6:59:49 PM 952 (0x03B8)
    No active process found with ID 3128 mtrmgr 3/4/2015 6:59:49 PM 2504 (0x09C8)
    Creation event received for process 1028 mtrmgr 3/4/2015 6:59:49 PM 952 (0x03B8)
    Unable to collect process information as process has terminated mtrmgr 3/4/2015 6:59:49 PM 952 (0x03B8)
    No usage will be tracked for process 1028, as failed to get owner info or executable file name 80004005 mtrmgr 3/4/2015 6:59:49 PM 952 (0x03B8)
    Termination event received for process 1028 mtrmgr 3/4/2015 6:59:49 PM 952 (0x03B8)
    No active process found with ID 1028 mtrmgr 3/4/2015 6:59:49 PM 2504 (0x09C8)
    Termination event received for process 4780 mtrmgr 3/4/2015 6:59:53 PM 952 (0x03B8)
    Thank you
    Loyan

    Hello,
    80004005 is a general error, this will not help with the issue. Check system status, component status.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • Is there any irreversible executable file for java?

    Is there any irreversible executable file for java? Because class files can be decompiled but .exe files can’t be decompiled (as far I know).
    Then how can I make my code secure and inaccessible?
    Thanks in advance.

    This question is discussed every now and then. Look for those discussions and also for obfuscators.

  • How do I include all the necessary files required for the DAQ Assistant to create an executable file?

    I am creating an executable file to run on a computer that does not have LabVIEW installed.  The problem is that I am using the DAQ Assistant.  The VI Hierarchy is rather large, and I am not sure how to include all of the required files to eliminate the error "The full development version of LabVIEw is required to fix the errors."  Attached is an image of the VI Hierarchy.
    Solved!
    Go to Solution.
    Attachments:
    hierarchy.jpg ‏419 KB

    Yes I did create an installer.  See image installernoDAQmx.jpg  
    When this is all I do I get an error that subvi is not included, a list of about 6 subvi's.  To eliminate this error I manually add the subvi from the dependencies list to the my computer list. This allows me to add them as support files.  This eliminates the error about subvi not included, but then I get the error I spoke of earlier.
    If I include the DAQmx I get an error.  See image installererror.jpg
    Not sure what MAX refers to?
    Attachments:
    installernoDAQmx.jpg ‏259 KB
    installererror.jpg ‏103 KB
    dependencies.jpg ‏344 KB

Maybe you are looking for

  • Syncing problems won't go away

    I have an annoying problem with my new computer. Whenever I want to add songs that I purchased from itunes to my ipod and connect it to my laptop, it requests I choose to erase and sync or to add my ipod songs to my library, either way it's a disaste

  • Discover group problem with cross tab report

    Hi, I'm working on a cross tab report in discoverer 4i and I'm having a problem with two of the colums. I'm doing a count on one field but because they are called something different they are being shown as two seperate columns rather than 1. I have

  • Can you link remote rollovers to images in an iFrame?

    I have a page called Jewelry in Dreamweaver with an iFrame on it that takes up half the right hand side of the page. The iFrame links to a page with all my thumbnail images. On the left hand side of my Jewelry page I want to have a larger version of

  • Does running multiple tasks on the multifunction DAQ card cuase any problems ?

    Dear all, I woul like to use the 6024E card for running atleast 3 tasks simultaneously, does it cause any problem ? Any software issues? I have a 3.0 GhHz HT processor with 256 MB Ram. Any issues with labview ?

  • If DBMS_LOB is include in a view I can't grant select on the view

    I have a view which includes a column that uses DBMS_LOB.SUBSTR( MyLob, 4000, 1 ).... The view works for the owner. When I attempt to grant select on it I get grant select on MyView ERROR at line 1: ORA-01720: grant option does not exist for 'SYS.DBM