AutopsySLogVizModule/src/AutopsySLogVizModule/DataContentViewerSlogViz.java
/**
    * Writes the data of a given Content to the disk.
    * 
    * @param con the Content that has to be written to the disk
    * 
    * @see Content
    */
Writes the data of a given Content to the disk.

@param con the Content that has to be written to the disk

@see Content
Writes the data of a given Content to the disk . @param con the Content that has to be written to the disk @see Content
private void writeFile(Content con){
        if (con == null){
            return;
        }
        String path = SLOGVIZ_FILE_PATH + File.separator + con.getName();
        File file = new File(path);
        if(file.exists() && file.canRead() && file.isFile()){
            return;
        }
        OutputStream os;
        try {
            os = new FileOutputStream(file);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(DataContentViewerSlogViz.class.getName()).log(Level.SEVERE, null, ex);
            return;
        }
        file.deleteOnExit();
        int byteRead;
        try {
            this.buf = new byte[(int)READ_LENGTH];
            long offset=0; 
            byteRead = con.read(this.buf, offset, READ_LENGTH); 
            while(byteRead != -1){
                os.write(this.buf); 
                offset += READ_LENGTH;
                this.buf = new byte[(int)READ_LENGTH];
                byteRead = con.read(this.buf, offset, READ_LENGTH); 
            }
        } catch (TskException | IOException ex) {
            Logger.getLogger(DataContentViewerSlogViz.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            os.flush();
            os.close();
        } catch (IOException ex) {
            Logger.getLogger(DataContentViewerSlogViz.class.getName()).log(Level.SEVERE, null, ex);
        }
        if(con.getName().endsWith(".gz")){
            unzipFile(con);
        }
    }
private void writeFile ( Content con ) { if ( con == null ) { return ; } String path = SLOGVIZ_FILE_PATH + File . separator + con . getName ( ) ; File file = new File ( path ) ; if ( file . exists ( ) && file . canRead ( ) && file . isFile ( ) ) { return ; } OutputStream os ; try { os = new FileOutputStream ( file ) ; } catch ( FileNotFoundException ex ) { Logger . getLogger ( DataContentViewerSlogViz . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; return ; } file . deleteOnExit ( ) ; int byteRead ; try { this . buf = new byte [ ( int ) READ_LENGTH ] ; long offset = 0 ; byteRead = con . read ( this . buf , offset , READ_LENGTH ) ; while ( byteRead != - 1 ) { os . write ( this . buf ) ; offset += READ_LENGTH ; this . buf = new byte [ ( int ) READ_LENGTH ] ; byteRead = con . read ( this . buf , offset , READ_LENGTH ) ; } } catch ( TskException | IOException ex ) { Logger . getLogger ( DataContentViewerSlogViz . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; } try { os . flush ( ) ; os . close ( ) ; } catch ( IOException ex ) { Logger . getLogger ( DataContentViewerSlogViz . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; } if ( con . getName ( ) . endsWith ( ".gz" ) ) { unzipFile ( con ) ; } }
Writes the data of a given Content to the disk.
Writes the data of a given Content to the disk .
//read //write //read