@Override
    public void copyStudyInto(String newName, Study study) {
        File newStudyDir = new File("./studies/", newName);
        
        if(newStudyDir.exists()) {
            // Override eixsting study
            
            // Need to delete directory contents before deleting directory
            for(File f : newStudyDir.listFiles())
                f.delete();
            newStudyDir.delete(); // Delete directory
        }
        
        // Create new directory
        newStudyDir.mkdir();
        
        // Copy images.
        for(Image i : study.getImages()) {
            File f = new File(newStudyDir, i.getName());
            
            try {
                ImageIO.write(i.getImageData(), "jpeg", f);
            } catch (IOException ex) {
                // Ignore IO exceptions; can't do anything about them.
                Logger.getLogger(LocalConnection.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        
        // Copy display state
        
        DisplayState state = study.getDisplayState();
        if(state != null) {
            File displayStateFile = new File(newStudyDir, ".displaystate");
            try {
                state.serialize(displayStateFile.getPath());
            } catch (IOException ex) {
                // Ignore IO exceptions; can't do anything about them.
                Logger.getLogger(LocalConnection.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        
    }