How to check for a compressed file

hi,
I need to restrict the user to upload only compressed files (zip,sit etc.).
how do u check whether the input file is compressed or not. is there any way to do that? or should i check only with the extension?
Thanuja.

Checking the extension is the best what you can do. You can also consider the java.util.zip API [1] to check if the file is decompressable, but that is rather expensive.
[1] http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/package-summary.html

Similar Messages

  • Want to know how to check for new line character in text file

    Hi All,
    I`m trying to read data from text file. However I`m not sure whether the data is in 1st line or nth line. Now I`m trying to read the text from the readline. But if text is "" and not NULL then my code fails. So I want to know how to check for new line character and go to next line to find the data. Please help.
    Thanks
    static int readandwriteFile(Logger logger,String filepath){
              BufferedWriter out = null;
              BufferedReader in = null;
              File fr = null;
              int get_count = 0;
              try     {
              if(new File(filepath).exists())
              fr= new File(filepath);
                        System.out.println("FileName: "+fr);
                   if(fr != null){
    in = new BufferedReader(new FileReader(fr));
                             String text = in.readLine();
                             if(text != null){
                             get_count = Integer.parseInt(text);
                             in.close();
                             else{
                                  get_count = 0;
         else{                    
    out = new BufferedWriter(new FileWriter(filepath));
         out.write("0");
                out.close();
                   }          //Reading of the row count file ended.
              catch(Exception e) {
                   e.printStackTrace();
              finally {
                   try{               if (in != null) {
                             in.close();
              if (out != null) {
                             out.close();
              catch(Exception e) {
                        e.printStackTrace();
              return get_count;
         }

    You are calling the readline() only once which means you are reading only the first line from the file...
    Use a loop (Do-While preferably)
    do{
    //your code
    }while(text == "")

  • How to check for a function module with its description and functionality

    Hi all,
    How to check for a function module,with its description and its functionality,in detail how can I know the purpose of a particular function module,how to search for a function module which suits my requirement .

    Hi,
    You can search a FM of your requirement by putting in the Key words and searching for a FM. Like * KEYWORD * and then pressing F4.
    Say for example you need to search something regarding converstion.
    Search for * CONVERT * and press F4.
    If there is something specfic like converting date to something you can give
    DATE * CONVERT *
    OR
    CONVERT * DATE *  and press F4.
    Once you narrow down your search you will have a Function module documentation inside the Function module. Please note that all the FMs willl not have documentation.
    Regards,
    Pramod

  • How to check for the sub folder in the document library Is already Exist using CSOM?

    Hi,
    My requirement is to create the  folder and sub folder in SharePoint document library. If already exist leave it or create the new folder and the subfolder in the Document library using client side object model
    I able to check for the parent folder.
    But cant able to check the subfolder in the document library.
    How to check for  the sub folder in the document library?
    Here is the code for the folder
    IsFolder alredy Exist.
    private
    string IsFolderExist(string InputFolderName)
    string retStatus = false.ToString();
    try
    ClientContext context =
    new ClientContext(Convert.ToString(ConfigurationManager.AppSettings["DocumentLibraryLink"]));
                context.Credentials =
    CredentialCache.DefaultCredentials;
    List list = context.Web.Lists.GetByTitle(Convert.ToString(ConfigurationManager.AppSettings["DocumentLibraryName"]));
    FieldCollection fields = list.Fields;
    CamlQuery camlQueryForItem =
    new CamlQuery();
                camlQueryForItem.ViewXml =
    string.Format(@"<View  Scope='RecursiveAll'>
    <Query>
                                            <Where>
    <Eq>
    <FieldRef Name='FileDirRef'/>
    <Value Type='Text'>{0}</Value>
                                                </Eq>
    </Where>
    </Query>
                                </View>",
    @"/sites/test/hcl/"
    + InputFolderName);
                Microsoft.SharePoint.Client.ListItemCollection listItems = list.GetItems(camlQueryForItem);
                context.Load(listItems);
                context.ExecuteQuery();
    if (listItems.Count > 0)
                    retStatus =
    true.ToString();
    else
                    retStatus =
    false.ToString();
    catch (Exception ex)
                retStatus =
    "X02";
    return retStatus;
    thanks
    Sundhar 

    Hi Sundhar,
    According to your description, you might want to check the existence of sub folder in a folder of a library using Client Object Model.
    Please take the code demo below for a try, it will check whether there is sub folder in a given folder:
    public static void createSubFolder(string siteUrl, string libName, string folderServerRelativeUrl)
    ClientContext clientContext = new ClientContext(siteUrl);
    List list = clientContext.Web.Lists.GetByTitle(libName);
    CamlQuery camlQuery = new CamlQuery();
    camlQuery.ViewXml =
    @"<View Scope='RecursiveAll'>
    <Query>
    <Where>
    <Eq>
    <FieldRef Name='FSObjType' />
    <Value Type='Integer'>1</Value>
    </Eq>
    </Where>
    </Query>
    </View>";
    //camlQuery.FolderServerRelativeUrl = "/Lib1/folder1";
    camlQuery.FolderServerRelativeUrl = folderServerRelativeUrl;
    ListItemCollection items = list.GetItems(camlQuery);
    clientContext.Load(items);
    clientContext.ExecuteQuery();
    Console.WriteLine(items.Count);
    if (0 == items.Count)
    //create sub folder here
    Best regards
    Patrick Liang
    TechNet Community Support

  • How to check for locks on a table inside a program?

    Hi Gurus,
    Kindly let me know how to check for a lock on a particular table inside a program.I know that we can see locks on table held by a user from transaction SM12 but my requirement is to check for lock on MARA/MARC/MARV if lock exist then bypass my code else do the code.
    Kindly suggest or give code to check for a lock on a particular table.
    Thanks in advance
    Sudipto

    FAQ.  Locked.

  • How to check for updates on SCM packages?

    Hey guys,
    I wondered for some time now how to check for updates on SCM packages, i.e. -git
    or -svn ones. Updates for binary packages are automatically updated by pacman,
    no problem there. Checking for updates on non-SCM packages from the AUR is
    easily done with one of the various helper tools available (personally, I use
    slurpy).
    However, SCM packages can change without their PKGBUILD changing, so I'm not
    notified that I should recompile and update them.
    Is there a "proper" way of doing this? Am I missing something?
    Thanks in advance!

    If your system is booting then u can say that your bootblks are installed.Usually BootBlks are present in 0 & 1 slice of UFS Filesystem
    /usr/platform/platform-name/lib/fs/ufs
    directory where ufs boot objects reside.
    An x86 FDISK partition for the Solaris software begins with a one-cylinder boot slice, which contains the partition boot program (pboot) in the first sector, the standard Solaris disk label and volume table of contents (VTOC) in the second and third sectors, and the bootblk program in the fourth and subsequent sectors. When the FDISK partition for the Solaris software is the active partition, the master boot program (mboot) reads the partition boot program in the first sector into memory and jumps to it. It in turn reads the bootblk program into memory and jumps to it. Regardless of the type of the active partition, if the drive contains multiple FDISK partitions, the user is given the opportunity to reboot another partition.

  • How to check for impacts due to upgrade

    We are plannining to upgrade from 4.7 to ECC6..How to check for impacts on FTP'S,shell scripts and RFC's etc due to the assesment..Please suggest

    Hi,
    FTP's and Shell scripts are OS dependant not SAP or Database dependant so there will be no change at all unless you upgrade OS too. RFC's are not afected as per guides, notes and my experience.
    I´m doing an upgrade from 4.6C to 6.0 with connections with at least 10 systems and none of them had an issue during tests
    Good luck

  • How to check for bootblk on Disk

    Does someone know how to check for bootblk on solaris disk.

    If your system is booting then u can say that your bootblks are installed.Usually BootBlks are present in 0 & 1 slice of UFS Filesystem
    /usr/platform/platform-name/lib/fs/ufs
    directory where ufs boot objects reside.
    An x86 FDISK partition for the Solaris software begins with a one-cylinder boot slice, which contains the partition boot program (pboot) in the first sector, the standard Solaris disk label and volume table of contents (VTOC) in the second and third sectors, and the bootblk program in the fourth and subsequent sectors. When the FDISK partition for the Solaris software is the active partition, the master boot program (mboot) reads the partition boot program in the first sector into memory and jumps to it. It in turn reads the bootblk program into memory and jumps to it. Regardless of the type of the active partition, if the drive contains multiple FDISK partitions, the user is given the opportunity to reboot another partition.

  • Could someone please explain how to check for flashback, to a beginner?

    Could someone please explain how to check for flashback, to a beginner?  Thanks.

    Install all of the available software updates.  If you have flashback it will be automatically removed.

  • How to check for missing fields in the file?

    Hi friends,
    I have a file to file scenario in which if any of the fields have a blank value, i have to put the file back in the source folder. If none of the fields are missing, the scenario should work normally.
    Can anybody tell me <b>how can i check for the field lengths</b> and if any of the fields are blank, <b>how do i send it back to the original folder.</b>
    Waiting for your responses,
    Divija.

    Hi Divija,
    >><i>how can i check for the field lengths</i>
    Since you need to basically check if the field has a value or not, i dnt think you need to check for the length of the field. Instead, you can use any one of the booloean functions available in the graphical mapping editor to check if the field has a value or not(filed value true or false)
    >><i>how do i send it back to the original folder.</i>
    You can maintain a flag variable in the target structure such that if any of the source fields donot have values, the flag's value becomes 1 else it remains 0.
    Now, you can check if the value of flag is equal to 1/0 in the bpm and accordingly send the data.
    If in case, you donot want the flag to come in the target file that is loaded/sent from the bpm in the end, i think even tat can be taklen care of.
    You can create two receiver communication channels and define one file adapter in each such that one has the destination as the actual target directory and the other has the original source directory as the destination.
    Regards,
    Sushumna

  • How to check if a specific file exist and which exit code to use ?

    Hi, First I'm not a scripting guy and I know almost nothing about VB scripting.
    I have a deployment of 6 tasks and I want to make sure that step # 2 will not be process if it failed in step #1, and so on for the 6 task.
    To do this, i have to run a vb script before installation or uninstalltion on each steps
    I'm trying to use a script (not from me) that i have modified for pre-uninstallation of software and also post-installation of the software.
    Pre-uninstallation: The script will look if the specified "exe" exist on the server and if so, than it will run the msiuninstall "application_name".
    If the uninstallation is successful, the post-installation script will check if the "exe" file exist again on the server, and it shouldn't find it (because it was deleted from the uninstallation), than it will return an exit code of successful
    to run the next process.
    Here an example:
    Step 1: Uninstall "Software#1" with msiuninstall Software#1.exe command
    Step 2: Uninstall "Software#2" with msiuninstall Software#2.exe command
    Step 3: Install "Software #3"with an .exe extension
    Step 4: Re install "Software #2" with an .msi extension
    Step 5: Re install "Software #1" with a .msi extension.
    Step 6: Send email to confirm the deployment is successful
    So i need to validate that step #2 will not process step #3 if it failled on # 2. It need to validate if the file exist before and after.
    At the end, Step 6 should send an email to confirm that the 6 steps of the deployment was completed without errors.
    Any idea how to do it ?
    Many many thanks for all the help !
    A desperate guy :)
    This is what i have
    'This script will look if an .exe file exist for a specific application.
    '=============================================================================================
    path = WScript.Arguments.Item(0)
    set objFSO = CreateObject("Scripting.FileSystemObject")
    If objFSO.FileExists(C:\Inetpub\wwwroot\Enterprise\EnterpriseWS\web.config) = true then
        exitCode = 0
    else
        exitCode = 1
    End If
    Wscript.Quit exitCode

    Since you are not a scripting guy here is a very good place to start:
    http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx
    ¯\_(ツ)_/¯

  • HOw to check for the Child Elements USing only SAX Parsr?

    HI Guyz,
    How to check whether there are any Child Elements in an XML file using ONLY SAX parser ??? I have a requirement of checking first whether there is any Child Elements exists for a Element or not and based on that I have to take certain actions. Can anyone suggest me How to do that ???
    Thanx
    KK

    Since SAX is event controlled, you wont know if there's a child element unless you actually bump into it with the Parser. You'll simply get another startElement event after your current one.
    /Tom

  • HT6114 how to check for malware on my mac

    My macpro is running slow all of a sudden.  How do i check for malware?

    No need, really. You've shown no evidence that malware would be causing the issue. Furthermore, OS X has its own built-in anti-malware protection. It's unlikely your problem is due to malware. See the following:
    Things You Can Do To Resolve Slow Downs
    If your computer seems to be running slower here are some things you can do:
    Start with visits to:     OS X Maintenance - MacAttorney;
                                      The X Lab: The X-FAQs;
                                      The Safe Mac » Mac Performance Guide;
                                      The Safe Mac » The myth of the dirty Mac;
                                      Mac maintenance Quick Assist.
    Boot into Safe Mode then repair your hard drive and permissions:
    Repair the Hard Drive and Permissions Pre-Lion
    Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    Repair the Hard Drive - Lion/Mountain Lion/Mavericks
    Boot to the Recovery HD:
    Restart the computer and after the chime press and hold down the COMMAND and R keys until the Utilites Menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD disk icon and click on the arrow button below.
    When the recovery menu appears select Disk Utility. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported, then click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the main menu. Select Restart from the Apple menu.
    Restart your computer normally and see if this has helped any. Next do some maintenance:
    For situations Disk Utility cannot handle the best third-party utility is Disk Warrior;  DW only fixes problems with the disk directory, but most disk problems are caused by directory corruption; Disk Warrior 4.x is now Intel Mac compatible.
    Note: Alsoft ships DW on a bootable DVD that will startup Macs running Snow Leopard or earlier. It cannot start Macs that came with Lion or later pre-installed, however, DW will work on those models.
    Suggestions for OS X Maintenance
    OS X performs certain maintenance functions that are scheduled to occur on a daily, weekly, or monthly period. The maintenance scripts run in the early AM only if the computer is turned on 24/7 (no sleep.) If this isn't the case, then an excellent solution is to download and install a shareware utility such as Macaroni, JAW PseudoAnacron, or Anacron that will automate the maintenance activity regardless of whether the computer is turned off or asleep.  Dependence upon third-party utilities to run the periodic maintenance scripts was significantly reduced since Tiger.  These utilities have limited or no functionality with Snow Leopard or later and should not be installed.
    OS X automatically defragments files less than 20 MBs in size, so unless you have a disk full of very large files there's little need for defragmenting the hard drive.
    Helpful Links Regarding Malware Protection
    An excellent link to read is Tom Reed's Mac Malware Guide.
    Also, visit The XLab FAQs and read Detecting and avoiding malware and spyware.
    See these Apple articles:
              Mac OS X Snow Leopard and malware detection
              OS X Lion- Protect your Mac from malware
              OS X Mountain Lion- Protect your Mac from malware
              About file quarantine in OS X
    If you require anti-virus protection I recommend using VirusBarrier Express 1.1.6 or Dr.Web Light both from the App Store. They're both free, and since they're from the App Store, they won't destabilize the system. (Thank you to Thomas Reed for these recommendations.)
    Troubleshooting Applications
    I recommend downloading a utility such as TinkerTool System, OnyX, Mavericks Cache Cleaner, or Cocktail that you can use for removing old log files and archives, clearing caches, etc. Corrupted cache, log, or temporary files can cause application or OS X crashes as well as kernel panics.
    If you have Snow Leopard or Leopard, then for similar repairs install the freeware utility Applejack.  If you cannot start up in OS X, you may be able to start in single-user mode from which you can run Applejack to do a whole set of repair and maintenance routines from the command line.  Note that AppleJack 1.5 is required for Leopard. AppleJack 1.6 is compatible with Snow Leopard. Applejack does not work with Lion and later.
    Basic Backup
    For some people Time Machine will be more than adequate. Time Machine is part of OS X. There are two components:
    1. A Time Machine preferences panel as part of System Preferences;
    2. A Time Machine application located in the Applications folder. It is
        used to manage backups and to restore backups. Time Machine
        requires a backup drive that is at least twice the capacity of the
        drive being backed up.
    Alternatively, get an external drive at least equal in size to the internal hard drive and make (and maintain) a bootable clone/backup. You can make a bootable clone using the Restore option of Disk Utility. You can also make and maintain clones with good backup software. My personal recommendations are (order is not significant):
      1. Carbon Copy Cloner
      2. Get Backup
      3. Deja Vu
      4. SuperDuper!
      5. Synk Pro
      6. Tri-Backup
    Visit The XLab FAQs and read the FAQ on backup and restore.  Also read How to Back Up and Restore Your Files. For help with using Time Machine visit Pondini's Time Machine FAQ for help with all things Time Machine.
    Referenced software can be found at MacUpdate.
    Additional Hints
    Be sure you have an adequate amount of RAM installed for the number of applications you run concurrently. Be sure you leave a minimum of 10% of the hard drive's capacity as free space.
    Add more RAM. If your computer has less than 2 GBs of RAM and you are using OS X Leopard or later, then you can do with more RAM. Snow Leopard and Lion work much better with 4 GBs of RAM than their system minimums. The more concurrent applications you tend to use the more RAM you should have.
    Always maintain at least 15 GBs or 10% of your hard drive's capacity as free space, whichever is greater. OS X is frequently accessing your hard drive, so providing adequate free space will keep things from slowing down.
    Check for applications that may be hogging the CPU:
    Pre-Mavericks
    Open Activity Monitor in the Utilities folder.  Select All Processes from the Processes dropdown menu.  Click twice on the CPU% column header to display in descending order.  If you find a process using a large amount of CPU time (>=70,) then select the process and click on the Quit icon in the toolbar.  Click on the Force Quit button to kill the process.  See if that helps.  Be sure to note the name of the runaway process so you can track down the cause of the problem.
    Mavericks and later
    Open Activity Monitor in the Utilities folder.  Select All Processes from the View menu.  Click on the CPU tab in the toolbar. Click twice on the CPU% column header to display in descending order.  If you find a process using a large amount of CPU time (>=70,) then select the process and click on the Quit icon in the toolbar.  Click on the Force Quit button to kill the process.  See if that helps.  Be sure to note the name of the runaway process so you can track down the cause of the problem.
    Often this problem occurs because of a corrupted cache or preferences file or an attempt to write to a corrupted log file.

  • [SOLVED] Check for old configuration files and directories in ~/

    Hello,
    Since I started with Arch I tried and uninstalled a few programs and would like to check for possible left overs in ~/
    I tried the "lostfiles" script, but it does not seem to check the home directory. Then I followed this: https://wiki.archlinux.org/index.php/Pa … ny_package - But using the suggested alias in my bash, it gives me the below:
    $ pacman-disowned-files
    [sudo] password for [my user]:
    bash: -path: command not found
    bash: /root: Is a directory
    bash: -print: command not found
    What am I doing wrong?
    Regards
    Martin
    Last edited by onslow77 (2015-02-04 23:52:44)

    Hello,
    ohh, I see, I need to do this (in directory where I put the script)
    sh pacman-disowned -files > test.txt
    That solved the usage of the commands, but it does not however list files [in the test.txt file] that do not belong to any package in my ~/ directory (I put a dummy file in my ~/ to see if it got noticed) - but it did not. So how can I list files and directories in my ~/ directory that is not put there by any package that currently is installed?
    Regards
    Martin
    Last edited by onslow77 (2015-02-04 22:49:11)

  • How to check for archivelog backup on a particular date or time?

    Dear All,
    We have RMAN full database, cumulative and archivelog backup(eg location: Diskgroup A) scheduled on a regular period basis. Assume archivelog location is Diskgroup B. The diskgroup B became full and unable to archive further, since no space. Unable to connect to database, connect internal only until freed error. alert log also shows that archiver error. So the solution for this to clear some space in diskgroup B by removing some old archive logs. In our environment, everyday the archive logs are stored in a separated folder arranged in date wise.  I can do that . But before clearing some space, i need to make sure that the folder( or any date folder what im going to delete) is backed up or not. How to check that? Any idea please?
    eg: i have archivelogs like this in folders
    01_11_2013/
    02_11_2013/
    03_11_2013/
    04_11_2013/
    05_11_2013/
    06_11_2013/
    If i want to remove the folder 01_11_2013/( and its contents ie archivelogs) , how to check whether the archivelogs in this folder 01_11_2013/ is backed up or not?
    Regards,

    Pradeepcmst wrote:
    Dear All,
    We have RMAN full database, cumulative and archivelog backup(eg location: Diskgroup A) scheduled on a regular period basis. Assume archivelog location is Diskgroup B. The diskgroup B became full and unable to archive further, since no space. Unable to connect to database, connect internal only until freed error. alert log also shows that archiver error. So the solution for this to clear some space in diskgroup B by removing some old archive logs. In our environment, everyday the archive logs are stored in a separated folder arranged in date wise.  I can do that . But before clearing some space, i need to make sure that the folder( or any date folder what im going to delete) is backed up or not. How to check that? Any idea please?
    eg: i have archivelogs like this in folders
    01_11_2013/
    02_11_2013/
    03_11_2013/
    04_11_2013/
    05_11_2013/
    06_11_2013/
    If i want to remove the folder 01_11_2013/( and its contents ie archivelogs) , how to check whether the archivelogs in this folder 01_11_2013/ is backed up or not?
    Regards,
    rman> list backup;
    Which begs the question .. why is the FRA getting filled in the first place?  Is it seriously undersized?  Are you not doing regular housekeeping with rman 'delete obsolete' and 'backup archivelog delete input'

Maybe you are looking for

  • External HDD just won't fly on USB... (and other random rants)

    Hi there Apple lovers and problem solvers! I have an external drive that can connect via firewire AND usb 2.0. The drive runs fine on the firewire but whenever I plug it into the USB I immediately get the alert message "USB Over Current Notice, A USB

  • Screen saver won't go on, laptop won't sleep!

    I've got a 17" laptop running 10.3.9. Everything used to be fine. Recently (after the latest Apple update? I'm not sure) I found that the laptop won't go to sleep. It's plugged in on my desk, and I've got the Energy Saver preference panel (set to "po

  • Filter query with Odata in UI5

    Hello All, Please suggest how to perform a filter operation for a similar query as below. The query runs good in browser but does nt turn up in UI5 (chrome security is disabled ) http://gatewayhostname:8000/sap/opu/odata/sap/ZSALESORDER_SRV/SalesOrde

  • *URGENT* importing third party package into Jdev project

    hi, our company has bought a thrid party package instead of developing one to speed up the project pace. Some how we cannot import the package into our project environment, this is what we do with the package. set the class path to where the *.jar fi

  • Javascript reference page items

    I have a popup window (page 3) in which a user chooses 3 values from seperate static select lists (hours, minutes, am/pm). I want these values to be returned into three seperate text fields on the page underneath (page 1). How do i reference them? At