FileInputStream and empty directories

How can I read an empty directory to a byte array? I'm currently reading it like this:
in = new BufferedInputStream(new FileInputStream(aux));
int len;
while ((len = in.read(buffer)) > 0)
   out.write(buffer, 0, len);Thanx in advance! :)

you don't.
if(aux.isDirectory()) {
byte[] dir = new byte[0];
} else {
The goal is to include an empty directory on a zip. I think I need to write something, to a subsequent ZipOutputStream - the following code isn't working properly:
    if(aux.isDirectory()){
                out.putNextEntry(new ZipEntry(aux.getPath()));
                out.write(new byte[0],0,0);       
    }It writes a 0 byte file to the Zip file, not a directory. It'll do the same thing if I remove "out.write(new byte[0],0,0);"
What am I doing wrong?
Thanx! :)

Similar Messages

  • Empty directories after system recovery

    I did a system recovery, then recovered backuped files with RecoveryMgr.
    That program claimed that it placed the files into c:/system recovery files,
    but I couldn't access those files. Please help. Thank you,
    Adrian

    Hello thats the behaviour of 10g RMAN when you backup it cleans up the backed up files not the directories. If you want I have small shell script that does cleanup empty directories :)
    -Sri
    << Fix.sh >>
    #!/bin/ksh
    # Author: Srikanth Pulikonda
    # Date: 20-Feb-2006
    # Purpose: This script will check empty directories
    # in archive destination and clean them up.
    # Local variables
    bkdir=/u06/oradata/SRI/flash_recovery_area/SRI/archivelog
    echo ${bkdir}
    echo " "
    # Loop through all directories and check for empty directories
    for i in `ls -l ${bkdir} | grep -v fix.sh | awk '{print $9}'`
    do
    fname=`ls $i`
    files=`ls $i | wc | awk '{print $1}'`
    if [ $files -eq 0 ];
    then
    echo "No files in folder: $i"
    echo "Files Count : $files"
    echo "Filename : $fname"
    echo "Action : You can delete this directory $i"
    echo "Now cleaning up the empty directory..."
    rmdir $i
    else
    echo "There are some files : $i"
    echo "Files Count : $files"
    echo "Filename : $fname"
    echo "Action : You cannot delete this directory $i"
    echo " "
    fi
    done

  • Arch-chroot and empty efivars

    Hi, i have one problem with the last 'archlinux-2013.08.01-dual.iso'.
    The problem is:
    after the command 'arch-chroot' in the chrooted system '/sys/firmware/efi/efivars' is empty.
    - the pc is booted in uefi mode.
    - in the system, '/sys/firmware/efi/efivars' is populated.
    with previous iso images in 'sys/firmware/efi/' there were two subdirectories:
    vars and efivars, both populated.
    When chrooted efivars is empty and vars is populated.
    In this way grub can install itself.
    With the latest iso image (2013.08.01) 'sys/firmware/efi/vars' not exist anymore, and with an empty 'sys/firmware/efi/efivars' i can't install grub.
    I tried 'modprobe efivars' in the chrooted system but nothing change.
    Some ideas?
    Sorry for my bad english.

    falconindy wrote:
    tychicus wrote:However, the mount point is still listed in /proc/mounts in the chroot environment!
    Not relevant -- /proc/mounts doesn't respect namespaces and subroots. Use /proc/self/mountinfo (from the chrooted shell) if you want an accurate portrayal of what's mounted in the chroot.
    Okay that makes sense then. Looking at /proc/self/mountinfo from the chrooted shell (without having mounted /sys/firmware/efi/efivars to a chroot directory) I don't see efivars. But if I
    mount --bind /sys/firmware/efi/efivars /mnt/sys/firmware/efi/efivars
    and then chroot, it shows up in /proc/self/mountinfo even though the directory is still empty.  Here's a subset of /proc/self/mountinfo:
    46 43 0:21 / /sys/firmware/efi/efivars rw,nosuid,nodev,noexec,relatime shared:11 - efivars efivars rw
    48 43 0:13 / /sys rw,nosuid,nodev,noexec,relatime shared:34 - sysfs sysfs rw
    Is the ordering important such that since the /sys mount comes after the /sys/firmware/efi/efivars it clobbers it, being a directory starting higher in the tree?
    EDIT: I just noticed something that may or may not be of importance. In the ISO environment, /sys/firmware/efi/vars contains a directory for each EFI variable, and those directories each have 5 files: attributes, data, guid, raw_var, and size. The /sys/firmware/efi/efivars directory contains regular files (as far as I can tell) for each of those variables. In my chroot environment, even without having done a mount --bind on the efivars directory, /sys/firmware/efi/vars is populated with regular files for each of the EFI variables.
    Last edited by tychicus (2013-08-20 15:17:40)

  • Null and empty string not being the same in object?

    Hello,
    I know that null and empty string are interpreted the same in oracle.
    However I discovered the strange behaviour concerning user defined objects:
    create or replace
    TYPE object AS OBJECT (
    value VARCHAR2(2000)
    declare
    xml xmltype;
    obj object;
    begin
    obj := object('abcd');
    xml := xmltype(obj);
    dbms_output.put_line(xml.getStringVal());
    obj.value := '';
    xml := xmltype(obj);
    dbms_output.put_line(xml.getStringVal());
    obj.value := null;
    xml := xmltype(obj);
    dbms_output.put_line(xml.getStringVal());
    end;
    When creating xml from object, all not-null fields are transformed into xml tag.
    I supposed that obj.value being either '' or null will lead to the same result.
    However this is output from Oracle 9i:
    <OBJECT_ID><VALUE>abcd</VALUE></OBJECT_ID>
    <OBJECT_ID><VALUE></VALUE></OBJECT_ID>
    <OBJECT_ID/>
    Oracle 10g behaves as expected:
    <OBJECT><VALUE>abcd</VALUE></OBJECT>
    <OBJECT/>
    <OBJECT/>
    However Oracle 9i behaviour leads me to the conclusion that oracle
    must somehow distinguish between empty string and null in user defined objects...
    Can someone clarify this behaviour?
    Thus is it possible to test if object's field is empty or null?

    However Oracle 9i behaviour leads me to the conclusion that oracle
    must somehow distinguish between empty string and null in user defined objects...
    Can someone clarify this behaviour?
    Thus is it possible to test if object's field is empty or null?A lot of "fixes" were done, relating to XML in 10g and the XML functionality of 9i was known to be buggy.
    I think you can safely assume that null and empty strings are treated the same by Oracle regardless. If you're using anything less than 10g, it's not supported any more anyway, so upgrade. Don't rely on any assumptions that may appear due to bugs.

  • Difference in Null and Empty String

    Hi,
    I have been wondering about the difference between Null and Empty String in Java. So I wrote a small program like this:
    public class CompareEmptyAndNullString {
         public static void main(String args[]) {
              String sNull = null;
              String sEmpty = "";
              try {
                   if (sNull.equalsIgnoreCase(sEmpty)) {
                        System.out.println("Null and Empty Strings are Equal");
                   } else {
                        System.out.println("Null and Empty Strings are Equal");
              } catch (Exception e) {
                   e.printStackTrace();
    This program throws Exception: java.lang.NullPointerException
         at practice.programs.CompareEmptyAndNullString.main(CompareEmptyAndNullString.java:10)
    Now if I change the IF Clause to if (sEmpty.equalsIgnoreCase(sNull)) then the Program outputs this: Null and Empty Strings are Equal
    Can anyone explain why this would happen ?
    Thanks in Advance !!

    JavaProwler wrote:
    Saish,
    Whether you do any of the following code, the JUnit Test always passes: I mean he NOT Sign doesnt make a difference ...
    assert (! "".equals(null));
    assert ("".equals(null));
    You probably have assertions turned off. Note the the assert keyword has nothing to do with JUnit tests.
    I think that older versions of JUnit, before assert was a language keyword (which started in 1.4 or 1.5), had a method called assert. Thus, if you have old-style JUnit tests, they might still compile, but the behavior is completely different from what it was in JUnit, and has nothing to do with JUnit at all.
    If you turn assertions on (-ea flag in the JVM command line, I think), the second one will throw AssertionError.

  • Check for null and empty - Arraylist

    Hello all,
    Can anyone tell me the best procedure to check for null and empty for an arraylist in a jsp using JSTL. I'm trying something like this;
    <c:if test="${!empty sampleList}">
    </c:if>
    Help is greatly appreciated.
    Thanks,
    Greeshma...

    A null check might not be you best option.  If your requirement is you must have both the date and time component supplied in order to populate EventDate, then I would use a Script Functoid that takes data and time as parameters.
    In the C# method, first check if either is an empty string, if so return an empty string.
    If not, TryParse the data, if successful, return a valid data string for EventDate.  If not, error or return empty string, whichever satsifies the requirement.

  • I put photos in trash and emptied it! Can I get files bacK?

    I threw my entire photo library in trash (don't ask) and emptied it. I've been trying to recover files with Data Rescue II -- have run it three times and every time, it sticks when I get to "Scanning Drive, Postprocessing CBR Data"
    The first time it said: remaining time = 16 mins. 2nd time: remaining time = 18 mins. This time it says: Remaining time about 17 mins.
    I started it last night at 10 pm. It's been stuck on "17 minutes remaining" since I got up this morning.
    ANyone have any suggestions for getting it to process the hard drive?
    Is there any other software I should try? I stopped using hard drive as soon as I realized what I'd done. I backed it up on external hard drive and am running off of that. (I know, I should have backed up BEFORE I deleted everything. Yikes)
    Thanks for any suggestions...!

    The File Salvage program is truly a god send. It had been recommended to me and admittedly I was a bit skeptical. Ultimately, I did decide to download and purchase the Sunday morning following my unfortunate mishap and try it.
    I am so happy that I did decide to buy and try it.
    The downside is that can be time consuming as it automatically assigns new generic file names / numbers to each file that necessitates the user to open each file to determine if it is a file that he/she wishes to rename and save.
    The upside is that I got all my files back and of course my sanity, as well.

  • 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.

  • What is difference between Null String and Empty String ?

    Hi
    Just i have little confusion that the difference bet'n NULL String and Empty String ..
    Please clear my doubte.
    Thankx

    For the same reason I think it's okay to say "null
    String" and "empty String "as long as you know they
    really mean "null String reference" and "empty String
    object" respectively. Crap. It's only okay to say that as long as *the one you're talking to" knows what it really means. Whether you know it or not is absolutely irrelevant. And there is hardly any ambiguity about the effects that a statement like "assign an object to a reference" brings. "Null String" differs in that way.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • VARCHAR2:: How to differnciate between NULL and empty string '' ?

    Hello to all,
    I'm looking for a possibility to differnciate between NULL and empty string '' in column of type VARCHAR2.
    I have an application relying on that there is a difference between NULL and ''.
    Is it possible to configure ORACLE in some way ?
    Thanx in advance,
    Thomas

    try check if a varchar variable has an empty string
    by checking its lengthAnd that would accomplish what? But see for yourself:
    DECLARE
      v_test VARCHAR2(10);
    BEGIN
      v_test := '';
      DBMS_OUTPUT.put_line(LENGTH(v_test));
      v_test := NULL;
      DBMS_OUTPUT.put_line(LENGTH(v_test));
    END; C.

  • Difference  between null vector and empty Vector

    What is the diffrence between null vector and empty vector.

    null vector means the JVM doesn't allocate memory.It doesn't exist
    in memory. NO instance!
    empty vector means the JVM allocated memory.It exists in memory.
    it's a instance than is accessabel.But only have on elements.
    GL&HF.

  • What is the difference between String Constant and Empty String Constant

    What is the difference between string constant which does not contain any value and the Empty string constant?
    While testing a VI which contain a normal string constant in VI analyzer, it gives error to change string constant with the empty string constant?
    Please Reply
    prabhakant
    Regards
    Prabhakant Patil

    Readability.
    Functionally, they are the same. From a coding standpoint, the Empty String Constant is unambiguous.
    It is empty and will always be; good for initialization. Also, because you can not type a value into and Empty String Constant, someone would need to conciously replace it to set a 'default' value that is something other than NULL.
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • Script Editor does not work. Panel blue and empty.

    Hi
    I installed Oracle Database XE yesterday on
    Acer TravelMate C300, Microsoft XP SP2 Tablet Edition
    and ..
    I cannot read SQL scripts
    I cannot access to the editing panel of Scripts Editor when I want to create a new script.
    I used System and HR login.
    The panel is blue and empty.
    Thank you for any information
    Best regards
    JRD120

    I cannot read SQL scriptsWhere you want to read SQL scripts?
    I cannot access to the editing panel of Scripts
    Editor when I want to create a new script.About which "Scripts Editor" you talking about? From TOAD?
    The panel is blue and empty.Panel??

  • TS4009 How do I clean up mail in my icloud?  I have already deleted old mail on all devices, and emptied the junk & deleted files, but it still shows that I am at max on my icloud. What do I do to free up space? (photos & apps do not take up that much roo

    How do I clean up mail in my icloud?  I have already deleted old mail (from all my e-mail accounts) on all devices, and emptied the junk & deleted files, but it still shows that I am at max on my icloud. What do I do to free up space? (photos & apps do not take up that much room).  When I go to manage storage on any device & it will display how much room each program or app is using, it still shows that my e-mail is taking up the most room.  Is there a way to actually log on to the icloud server to manage what it stored there?  If so, how do I do it?  Also, on a related subject,  why does my mail not sync accross all devices?   ie. when I delete an email on one device, why do I still see it on all my other devices?  How can I change this?
    I have an iphone5, ipad2, ipod 4th gen, ipod 3rd gen, all running on my same apple id - but I have a PC not a Mac home computer - is this part of the problem?  Looking to upgrade to a Mac sometime this year...
    Thank-you for the help!

    beckyfromoz wrote:
    I do have the Time Capsule and spoke to Apple Care here in Sydney about it yesterday.  They told me my mail is not backed up there unless I create a special folder. I just tried ringing them again but Apple Care is closed today...
    Mail is backed up automatically. If you make backups automatically, open Mail application and then, open the Time Machine app (in /Applications/Utilities). You will access to the Time Machine interface, and you will be able to see all your mails of all the backups you have, and you will be able to restore them. It means that your mails are backed up onto the Time Capsule

  • I deleted the photos via Finder and empty trash long time ago. The thing is, that I want to recover one event or album.  The event appears in the iphoto but when open, it shows "!". Is it possible to recover the photos?

    I deleted the photos via Finder and empty trash long time ago. The thing is, that I want to recover one event or album.  The event appears in the iphoto but when open, it shows "!". Is it possible to recover the photos?

    No.  When you removed the photos via the finder you damage the library.  Photos should always be removed from the library using iPhoto, never with the Finder.
    If you have a Time Machine backup of the library from before you deleted the photos you can restore the library to the Desktop and export that album from it to import into your current library.
    It's been too long to be able to try one of the file recovery applications.  You sure to have overwritten those files with new files since them.
    OT

Maybe you are looking for

  • HOW TO DELETE PHONE NO. RECORD IN CALL DIVERT

    Hi! Please help me, I have recently activated a call divert if the phone is not answered. My problem is, when I deactivate this function. The record of the phone number that I have used is still appearing, how do I delete this record?

  • Different Currency in Purchase order and Invoice

    Hi MM Gurus, Kindly suggest me as to how to map the following scenario is SAP.              Purchase order is placed on the Vendor in currency USD. Vendor is from India.Excise details are not captured in Purchase order. Vendor invoice is in currency

  • I can't stop po-ups in windows7

    I am using windows 7 and can't stop pop-ups. The instruction you give for windows xp do not apply for windows 7 as there is no mention of pop-ups in firefox options. .

  • Email signature and Mail Format

    Blackberry blend is very unique and useful software. But I have a couple of problem to use this software... 1. Email signature Please tell me how to insert email signature. I would like to use email signature just as blackberry smartphone. 2. Email f

  • Mesh parent

    I have few questions for mesh network: what exactly is a parent, child and neigbor in mesh network 1.can a mesh access point act as parent or child to another mesh neighbor ? 2. an electronic temperature gauge connects to root access point eventhough