Find out if string is valid file name?

Is there a platform-independent method in the standard API to determine if a string contains only valid filename characters, and if not, convert it?

How about something like
File f = new File(String pathname)
then
if(f.isDirectory())
And
if(f.isFile())
And
if(f.exists())This would only work for existing files. You could try File.exists() as a first effort, and if this returned false, try creating a new directory with File.mkdirs(). Of course, this only works for local code (i.e. it wouldn't work in an Applet), and wouldn't work (for example) if the path contained a drive letter that didn't exist on your machine.
RObin

Similar Messages

  • Find out varchar2 string NULL columns and Empty columns

    Hi dev's ,
    my requiremnt is to find out the string columns Names of whose storing NULL values and EMPTY strings. for that i had written below code. it's getting some error.
    SET ECHO OFF;
    SET FEEDBACK OFF;
    SET SERVEROUTPUT ON;
    SET VERIFY OFF;
    SET PAGES 0;
    SET HEAD OFF;
    spool D:\stringnull.csv
    DECLARE
      v_tab_indent NUMBER(5);
      v_col_indent NUMBER(5);
      v_val1       VARCHAR2(20);
      v_val2       VARCHAR2(20);
      v_query1     VARCHAR(500);
      v_query2     VARCHAR(500);
    BEGIN
      --DBMS_OUTPUT.ENABLE(100000);
      SELECT MAX(LENGTH(table_name))+1,MAX(LENGTH(column_name))    +1
      INTO v_tab_indent,v_col_indent
      FROM user_tab_columns
      WHERE data_type='VARCHAR2';
    FOR i IN
      (SELECT table_name,
        column_name
      FROM user_tab_columns
      WHERE data_type IN ('NVARCHAR2', 'CHAR', 'NCHAR', 'VARCHAR2')
      ORDER BY table_name,
        column_name
      LOOP
        v_query1:='SELECT NVL('||i.column_name||',0) AS VAL    
                  FROM '||i.table_name||' where '||i.column_name||' IS NULL';
        v_query2:='SELECT '||i.column_name||' AS VAL    
                  FROM '||i.table_name||' where '||i.column_name||'=''''';
        --dbms_output.put_line(v_query1);
       -- dbms_output.put_line(v_query2);
        EXECUTE immediate v_query1 INTO v_val1;
        EXECUTE immediate v_query2 INTO v_val2;
        dbms_output.put_line (rpad(i.table_name,v_tab_indent,' ')||','||rpad(i.column_name,v_col_indent,' ')||' ,'||v_val1||','||v_val2);
      END LOOP;
    END;
    Spool OFF
    Set echo on
    Set feedback onERROR:
    Error report:
    ORA-01403: no data found
    ORA-06512: at line 31
    01403. 00000 -  "no data found"
    *Cause:   
    *Action:
    set feedback onpls help me on this issue..
    Thanks,

    Example:
    SQL> DECLARE
      2    v_val       VARCHAR2(20);
      3    v_query1     VARCHAR(32767);
      4  BEGIN
      5   FOR i IN (SELECT table_name, column_name FROM user_tab_columns
      6             WHERE data_type IN ('NVARCHAR2', 'CHAR', 'NCHAR', 'VARCHAR2')
      7             ORDER BY table_name, column_name
      8            )
      9   LOOP
    10     v_query1 := 'SELECT count(*) FROM '||i.table_name||' where '||i.column_name||' IS NULL';
    11     EXECUTE immediate v_query1 INTO v_val;
    12     dbms_output.put_line(rpad(i.table_name,30,' ')||' : '||rpad(i.column_name,30,' ')||' : '||v_val);
    13   END LOOP;
    14  END;
    15  /
    CHILD_TAB                      : DESCRIPTION                    : 0
    DEPT                           : DNAME                          : 0
    DEPT                           : LOC                            : 0
    EMP                            : ENAME                          : 0
    EMP                            : JOB                            : 0
    MYEMP_OLD                      : ENAME                          : 0
    MYEMP_OLD                      : JOB                            : 0
    MYNULLS                        : ENAME                          : 0
    MYNULLS                        : JOB                            : 4
    PARENT_TAB                     : DESCRIPTION                    : 0
    T                              : CHAR_VALUE                     : 0
    TABLE1                         : COL1_DESC                      : 0
    PL/SQL procedure successfully completed.

  • How to find out the format of a file?

    Is there any way to find out the format of a file?
    By format I mean binary, text, .doc, .rtf, etc. Please kindly help

    The unix file command:
    file *
    foo.doc ms-office file / word
    bar.png png image, 32x32 pixels, no transparency
    moo.hhml html text
    note that as in the last - file names are ignored, it works by checking the beginning of each file's data against it's database, and as in #2 it can sometimes see a lot more than just the file format.
    Don't know of a windows port, you could try cygwin

  • How can I find out  the strings that will be presented to the UI

    Hi All,
    I am working on a Swing based application (Swing based UI)
    I am requested to do the following on the bytecode of that application:
    I am supposed to find out what strings from within that bytecode will be presented to the UI and what will be used for an internal usage.
    i have no way of running the application to verify that, i can only work on the static bytecode files.
    hard question ha?
    Thanks,
    EItan.

    You would of course have to run it. Either via a VM or recreating a VM yourself.
    As an example of that how would you figure out what string occurs in the following (pseudo) code?
    String msg = (cnt > 1) ? ("files=" + cnt) : ("file=" + cnt);
    if (cnt > 1) DisplayMessage(msg);

  • How can I find out which .pst or .ost file itunes referres to when synchronising with outlook

    I´ve switched to iphone 4S from my 3Gs and would like to "clean" my itunes Sync before I use the new phone. Problem is, that the synchronisation with Outlook 2003 doesn´t work anymore. I guess the reason is that itunes refers to an old .ost or .pst file on my computer. I ve got several outlook profiles and changed from exchange to pop3. My question: How can I find out which .pst or .ost file itunes referres to?
    Thanks a lot in advance :-)

    Select the tune and then - Get Info - in the dialog box is a note of the Apple ID used to purchase.
    MJ

  • How do I find out where iTunes thinks missing files are?

    I have several hundred "missing" files in my iTunes library but they are all actually on the computer. But I don't remember where the were previously. I add dozens of songs at a time to my library all the time and there is no Earthly way for me to constantly remember where they were before. I don't just want to reimport the files because I have several hundred playlists with these files and it would be completely stupid to edit them all one at a time when all I need to do is to move them back to where iTunes thinks they should be. So where is that? The Windows media player has a column that displays file location. Why doesn't iTunes? (This is so stupid. It makes things -not just this- so much easier when you have the file location in the music list in your music player.)
    Is there a way to find out where iTunes thinks the missing files should be at?

    Chris CA wrote:
    How do I find out where iTunes thinks missing files are?
    The exclamation mark means ITunes doesn't think they are anywhere.
    If you right click - get info on a song then view the Info tab, you will see where iTunes last used it from.
    I'm not a newbie. I know quite a lot about iTunes. You sound like you don't though because if you did you would know that this is not true. If you "right click - get info on a song" (pressing cancel to the Locate popup) "then view the SUMMARY (not info) tab" you will see "Not Available" where the file location usually is. I wouldn't have asked this question if I hadn't gone through the steps already.
    Thanks for trying though. Next time, please try the advice before you give it.
    I add dozens of songs at a time to my library all the time and there is no Earthly way for me to constantly remember where they were before
    You should not have to remember anything about where they were.
    I agree.
    Are you always moving them around?
    When I install a new hard drive. Yes. I generally keep everything organized and I let iTunes keep the folder organized but several years ago I used windows media player to organize my media.
    Frankly I don't know HOW the recent songs/videos/etc. go missing. But some do. Maybe I accidentally move a folder without realizing it. Mistakes happen. Then I need to move it back but since I didn't know I did it in the first place I can't possibly be expected to remember where I moved it from.
    Do you have iTunes prefs -> Advanced Keep ITunes music folder organized ticked and Copy files to iTunes ... ticked?
    *OF COURSE!* Again, I'm not a newbie.
    I have several hundred playlists with these files
    Why would you have several hundred playlists?
    I don't mean to sound rude but you sound like an Apple fanboy. Are you trying to tell me how I should use my own program? The answer to the question is I am a salsa instructor/DJ and I am constantly adding songs and videos to my library. Every month I have various salsa events, classes and performances that I do. I use my iPhone for the music. I need to maintain the playlists because students/teachers/studios/clubs/bars/churches/etc. call me back and want a repeat of the great salsa night I gave them a year ago. Naturally my playlists are highly organized into folders. So, I still have them and I need them.
    Apple has its own ideas about how people should use its stuff but everyone is unique and our needs therefore are unique too. Apple doesn't realize this and still wants us to do things "the Apple way" even though "the Apple way" only works well for people who want their hand held through everything. This is why I say you sound like a fanboy. You don't know my situation and question if I need hundreds of playlists. I do.
    I just need an answer to the question.
    Thank you for your reply though. It gave me hope, for a time.

  • ITunes No Longer Runs--iTunes Helper Resources Not a Valid File Name

    I made a dumb mistake (I think) and tried to install iTunes onto an SD card.  At first, my computer would only let me open iTunes if the SD card was installed.  I tried to reinstall to the C drive, but keep getting the "I Tunes Helper Resources not a Valid File Name" message.  At this point I want to uninstall everything and start over, but I'm afraid I'll lose my music.  I still have all the files but, of course, none will open since I don't have a properly installed iTunes anymore.   Would appreciate any assistance in uninstalling, reinstalling and saving my current music files.

    Here's what I decided to do.  Fortunately, all the files were still available, so I simply backed them up from my iTunes Music Library onto a 32 GB flash drive then transferred the new stuff onto an older computer in my office with an older version of iTunes.  I had to do this in several shifts since I have more than 32GB of music.  Everything that transferred plays well.  Next I'll try to wipe iTunes completely off the new computer, reinstall an older version of iTunes and then reload all the files onto the new computer.  What a PITA!

  • Unable to generate csr, Please use a valid file name

    I've been attempting to generate a new certificate signing request on our Exchange 2013 server.  In the past we've never had a problem but we seem to be stuck today.  When we try to output the new csr to one of our network shares we see the following
    error.  
    "Please use a valid file name when you run the New-ExchangeCertificate cmdlet on server server1 with the -RequestFile parameter. The file should not exist in target folder. Parameter name: RequestFile"
    We've use this share location before without problems, the Exchange Trusted Subsystem has write intermissions on this location as described online but we still receive the error.  I've tried creating new locations but haven't had any success.
    Any suggestions?
    Thanks

    Hi,
    We can access the Exchange Certificate Management UI through the EAC in Exchange 2013 by selecting
    Servers and then Certificates to create a new certificate to have a try.
    Alternatively, we can try the following command:
    $Data = New-ExchangeCertificate -GenerateRequest -SubjectName "c=US, o=contoso inc, cn=server.contoso.com" -DomainName mail.contoso.com, contoso.com, autodiscover.contoso.com -PrivateKeyExportable $true
    Set-Content -path "C:\Certificates\MyCertRequest.req" -Value $Data
    Regards,
    Winnie Liang
    TechNet Community Support

  • Where do I go to find out what is registered in my name. thanks

    where do I go to find out what is registered in my name, thanks

    If you go to https://expresslane.apple.com/, assuming you're in Nepean, Ontario, click on My Products, sign in and your product should be listed there.
    Or do https://supportprofile.apple.com/MySupportProfile.do
    Message was edited by: K.S. added info

  • C#: 'Not a Valid File Name' error when I know the name and link are correct.

    I'm receiving "Not a valid file name" when I know I have used this link before and the filename is spelled correctly. I'm not sure if I should be looking at something else. This is my connection code.  It fails on "conn.Open()".
    For security reasons, I edited the link... it is not a working link for this question.
    private void InitializeDBConnection()
    strConn = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=http://database.storage.net/App_Data/Tracking.mdb";
    MessageBox.Show(strConn);
    MyConn = new OleDbConnection(strConn);
    MyConn.Open();
    SV

    A database must be locally available via the filesystem, e.g. an UNC path would do it also.

  • How can i find out the Location of fmx file in the forms

    Hi,
    I want to find out the drive name,WHich Contains Fmx file. How can i find it out(at run time) .
    It should be found inside the form.So that i can pass it as a parameter to a Procedure.
    Thanlks in advance.
    regards,
    Alok Dubey

    hi,
    if you are using Client/Server forms with d2kwutil then this should return form full name :
    win_api_environment.get_working_directory() || get_form_property(:System.Current_Form,FILE_NAME)
    engin.

  • How do I find out and the delete "other" files being stored on my drive?

    My Mac Air HD says it has 17 GB left of free memory space.
    76 GB says of "Other"
    How do I find out what "other" is, and delete it to free space.
    This is a brand new, Mac. I just got it in December and I have no pictures saved in it.
    Thank you

    For information about the Other category in the Storage display, see this support article. If the Storage display seems to be inaccurate, try rebuilding the Spotlight index.
    Empty the Trash if you haven't already done so. If you use iPhoto, empty its internal Trash first:
              iPhoto ▹ Empty Trash
    Do the same in other applications, such as Aperture, that have an internal Trash feature. Then restart the computer. That will temporarily free up some space.
    According to Apple documentation, you need at least 9 GB of available space on the startup volume (as shown in the Finder Info window) for normal operation—not the mythical 10%, 15%, or any other percentage. You also need enough space left over to allow for growth of the data. There is little or no performance advantage to having more available space than the minimum Apple recommends. Available storage space that you'll never use is wasted space.
    When Time Machine backs up a portable Mac, some of the free space will be used to make local snapshots, which are backup copies of recently deleted files. The space occupied by local snapshots is reported as available by the Finder, and should be considered as such. In the Storage display of System Information, local snapshots are shown as  Backups. The snapshots are automatically deleted when they expire or when free space falls below a certain level. You ordinarily don't need to, and should not, delete local snapshots yourself. If you followed bad advice to disable local snapshots by running a shell command, you may have ended up with a lot of data in the Other category. Ask for instructions in that case.
    See this support article for some simple ways to free up storage space.
    You can more effectively use a tool such as OmniDiskSweeper (ODS) or GrandPerspective (GP) to explore the volume and find out what's taking up the space. You can also delete files with it, but don't do that unless you're sure that you know what you're deleting and that all data is safely backed up. That means you have multiple backups, not just one. Note that ODS only works with OS X 10.8 or later. If you're running an older OS version, use GP.
    Deleting files inside a photo or iTunes library will corrupt the library. Changes to such a library must be made from within the application that created it. The same goes for Mail files.
    Proceed further only if the problem isn't solved by the above steps.
    ODS or GP can't see the whole filesystem when you run it just by double-clicking; it only sees files that you have permission to read. To see everything, you have to run it as root.
    Back up all data now.
    If you have more than one user account, make sure you're logged in as an administrator. The administrator account is the one that was created automatically when you first set up the computer.
    Install the app you downloaded in the Applications folder as usual. Quit it if it's running.
    Triple-click anywhere in the corresponding line of text below on this page to select it, then copy the selected text to the Clipboard by pressing the key combination command-C:
    sudo /Applications/OmniDiskSweeper.app/Contents/MacOS/OmniDiskSweeper 2>&-
    sudo /Applications/GrandPerspective.app/Contents/MacOS/GrandPerspective 2>&-
    Launch the built-in Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad and start typing the name.
    Paste into the Terminal window by pressing command-V. You'll be prompted for your login password, which won't be displayed when you type it. Type carefully and then press return. You may get a one-time warning to be careful. If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator. Ignore any other messages that appear in the Terminal window.
    The application window will open, eventually showing all files in all folders, sorted by size. It may take a few minutes for the app to finish scanning.
    I don't recommend that you make a habit of doing this. Don't delete anything as root. If something needs to be deleted, make sure you know what it is and how it got there, and then delete it by other, safer, means. When in doubt, leave it alone or ask for guidance.
    When you're done with the app, quit it and also quit Terminal.

  • How to find out the end of the file in java

    hi friends,
    I am reading a file char by char. So how can I check for end of the file. I va a integer of the character and a string which has hex value of the character.
    but when I execute the pgm, it shows out of memory error. overflow of the heap.
    can anyone help???
    thanks in advance...
    bye

    There is no "type of file". It's all zeroes andones.
    thing is am wrintin a file. I want to set the
    type(extension) to be .iso. how can i do that???If you want to make the extension ".iso" then just end the file name with ".iso".
    If you want to make the "type" iso, so that it can be manipulated by an iso application or whatever, then you have to make sure the bytes you write are of the proper format.
    As already stated: Files don't have a type.

  • How to find out the primary and failover DNS name

    Hi;
    This sounds very stupid, but could some one please tell me how to find out the name/dns name of the primary and failover server without using the CDS console.
    any help is appreciated

    Is this what you want?
    $ /usr/lib/ldap/ldap_cachemgr -g
    cachemgr configuration:
    server debug level 0
    server log file "/var/ldap/cachemgr.log"
    number of calls to ldapcachemgr 12729
    cachemgr cache data statistics:
    Configuration refresh information:
    Previous refresh time: 2005/08/07 23:54:59
    Next refresh time: 2005/08/08 00:55:00
    Server information:
    Previous refresh time: 2005/08/14 15:15:00
    Next refresh time: 2005/08/15 03:15:00
    server: ldap1.example.com, status: UP
    server: ldap2.example.com, status: UP
    server: ldap3.example.com, status: UP
    Cache data information:
    Maximum cache entries: 256
    Number of cache entries: 0
    Gary

  • Extracting string from a file name

    Hello,
    I have a legacy (read: I didn't build it) SharePoint list  that includes some validation when uploading files that's giving me some trouble.
    Basically, our users are required to add files to a list in a certain filename format and based on the naming convention are approved/rejected and routed to the appropriate location.
    One of the validations looks at a section of the file name and compares it to a folder name in the library.
    For example, the file name format is XX_AAA_999_2014_05.xlsx and that matches on the folder name of /submissions/2014_05
    Currently the rule says look at the last 7 characters of the folder and the 7 characters starting at position 12 of the filename and make sure they match.
    The problem is the 999 in the example above is a sequential identifier to the project a file is associated with... e.g. they range from project 000 to project 999. We've now hit project 1000 so file being added for project 1000 (and beyond) fails because
    the starting position has shifted one spot. (Note: we have active 3 digit projects so I cannot simply change that to be position 13... not to mention what that does to my history).
    So, my task is to come up with something that can accomodate 3 or 4 digit numbers.
    I'm trying to stick as closely to the original setup so I don't mess up the history so I'm looking at other methods of getting to the same data in the string.  Another problem is that the file names include the extension and the extension can be 3 (pdf)
    or 4 (xlsx) characters long.
    I've tried this:  =LEFT([Source File Name],SEARCH(".",[Source File Name])-1)
    but that brings back everything in front of the period and I need just the 7 preceeding characters.  Is there a way to limit the number of chars a LEFT() function returns?
    In a nutshell, the 4 variations of file names are as follows of which I need to extract the
    bolded section.:
    ZZ_AAA_999_2014_05.xls
    ZZ_AAA_999_2014_05.xlsx
    ZZ_AAA_1000_2014_05.xls
    ZZ_AAA_1000_2014_05.xlsx
    Thanks!
    Kevin

    Hi,
    According to your description, you might want to retrieve the string “2014_05” from the file name.
    I would suggest you create a SharePoint Designer workflow and implement your logic of handling the filename.
    In SharePoint Designer 2010, there are already some useful utility workflow actions which can enable users to deal with the various requirements come from the business scenarios.
    For the string handling, you can consider to use the
    Utility Actions:
    http://msdn.microsoft.com/en-us/library/office/jj164026(v=office.15).aspx
    Another two links about creating SharePoint Designer workflow for your reference:
    http://office.microsoft.com/en-001/sharepoint-designer-help/introduction-to-designing-and-customizing-workflows-HA101859249.aspx
    http://www.codeproject.com/Tips/415107/Create-a-Workflow-using-SharePoint-Designer
    Thanks
    Patrick Liang
    Forum Support
    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]
    Patrick Liang
    TechNet Community Support

Maybe you are looking for

  • What are the settings for  rework order  quality inspection

    HI, Iam doing production order confirmation at the GR time some oprations are rejected.that operations i want too rework order CO07 process without GR ,i want to Quality inspection in REWork order. What are the settings for rework order Quality inspe

  • Getting the current path of the file in a JavaBean

    Hello, I'm using a JavaBean with a jsp code. The JavaBean :     public String  ValidateUser(String user,String pass)           String Name = user;           String Pass = pass;           String  ReturnValue = "NOT OK";         try              Class.

  • Slideshow gallery in Dremweaver CS5

    I believe on older verions of Creative Suite there was a tool to put in a slideshow. Is it possible to do this or do I need to use a program like Flash to do so? If that's the case, is there an easy way to do this that doesn't involve a great dela of

  • ITunes keeps saying damaged library

    Dunno whats happened but everytime now when i connect my ipod video itunes always pop up with an error message before it opens saying something along the lines of 'itunes library is damaged, do you want to replace this file' or something like that, a

  • Smart form where used list

    Hi All, I want to change a smart form interface, before that I have to know where used list of this smart form but I can't. Could any one tell me how I can see the where used list of smart form. thanks in advance chetan vishnoi