public boolean importHistoryJPHA(String myuin, String dir) throws IOException {

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

        localDataOutputStream.writeUTF("JPHA");

        
        localDataOutputStream.writeUTF(myuin);
        
        // 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 + ".jpha"))
                {
                    continue;
                }
                
                // get contact uin - strip extension of filename
                contactuin = filename.substring(0, filename.length() - 4);
                
                InputStream localFile = new FileInputStream(importDir + "\\" +  filename);
                
                
                localDataOutputStream.writeUTF(contactuin);        
                
                // write cache to jpha file
                makeCacheFile(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
                    makeHstFile(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;
    }