/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package socius.adapter;
import com.healthmarketscience.rmiio.GZIPRemoteInputStream;
import com.healthmarketscience.rmiio.RemoteInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Ana
*/
public class ArquivoWindows extends UnicastRemoteObject implements Arquivo{
private File file;
private FileInputStream inputStream;
private long tamanho;
public ArquivoWindows(String path) throws RemoteException {
file = new File(path);
tamanho = file.length();
if (!file.isFile()) {
try {
file.createNewFile();
} catch (IOException ex) {
Logger.getLogger(ArquivoLinux.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
@Override
public File getFile() throws RemoteException {
return file;
}
@Override
public RemoteInputStream getStream() throws RemoteException {
RemoteInputStream stream = null;
try {
stream = new GZIPRemoteInputStream(new FileInputStream(file));
} catch (FileNotFoundException ex) {
} catch (IOException ex) {
}
return stream;
}
@Override
public void setFile(File file) throws RemoteException {
this.file = file;
}
@Override
public long getTamanho() throws RemoteException {
return tamanho;
}
}