public boolean importHistoryJHA2(String myuin, String dir) throws Exception {

        String contactuin = "";
        
        File importDir = new File(dir);
        
        // make output file in dir with history files
        
        File outputFile = new File(importDir + "\\" + myuin + ".jha2");
        
        DataOutputStream localDataOutputStream = new DataOutputStream(new FileOutputStream(outputFile));
        
        // write header and users uin

        localDataOutputStream.write("JHA2".getBytes());

        writeUIN(myuin, localDataOutputStream);
        
        localDataOutputStream.writeShort(10);
        
        // get files in directory
        String[] children = importDir.list();
        
        if (children == null) {
            // Either dir does not exist or is not a directory
        } else {
            for (int i=0; i<children.length; i++) {
                // Get filename of file or directory
                String filename = children[i];
                
                // if there already output file - skip it
                if (filename.equals(myuin + ".jha2"))
                {
                    continue;
                }
                
                // get contact uin - strip extension of filename
                contactuin = filename.substring(0, filename.length() - 4);
                
                InputStream localFile = new FileInputStream(importDir + "\\" +  filename);                
                
                writeUIN(contactuin, localDataOutputStream);        
                
                // write cache to jpha file
                localDataOutputStream.writeInt(45);
                localDataOutputStream.write("UNI".getBytes());
                makeCacheFileJHA2(localDataOutputStream, myuin);
                
                // make a temp file for history file ( to get proper history length )
                File tempfile = File.createTempFile(contactuin, ".hst");
                
                tempfile.deleteOnExit();
                
                DataOutputStream tempOutStream = new DataOutputStream(new FileOutputStream(tempfile));
                
                try {
                    // write proper history to temp file
                    makeHstFileJHA2(myuin, contactuin, localFile, tempOutStream);
                } catch (ParseException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    return false;
                }
                
                // write temp file to jpha file
                readTempFile(tempfile, localDataOutputStream);
            }
        }

        return true;
    }