1 2 3 package com.db4odoc.f1.blobs; 4 5 import java.io.File ; 6 7 import com.db4o.ext.Status; 8 import com.db4o.types.Blob; 9 10 11 public class CarImage { 12 Blob blob; 13 private String fileName = null; 14 private String inFolder = "blobs\\in\\"; 15 private String outFolder = "blobs\\out\\"; 16 17 public CarImage() { 18 19 } 20 21 public void setFile(String fileName){ 22 this.fileName = fileName; 23 } 24 25 public String getFile(){ 26 return fileName; 27 } 28 29 public boolean readFile() throws java.io.IOException { 30 blob.readFrom(new File (inFolder + fileName)); 31 double status = blob.getStatus(); 32 while(status > Status.COMPLETED){ 33 try { 34 Thread.sleep(50); 35 status = blob.getStatus(); 36 } catch (InterruptedException ex){ 37 System.out.println(ex.getMessage()); 38 } 39 } 40 return (status == Status.COMPLETED); 41 } 42 43 public boolean writeFile() throws java.io.IOException { 44 blob.writeTo(new File (outFolder + fileName)); 45 double status = blob.getStatus(); 46 while(status > Status.COMPLETED){ 47 try { 48 Thread.sleep(50); 49 status = blob.getStatus(); 50 } catch (InterruptedException ex){ 51 System.out.println(ex.getMessage()); 52 } 53 } 54 return (status == Status.COMPLETED); 55 } 56 } 57 | Popular Tags |