mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-12-28 04:41:37 -08:00
Adding Data Store implementations for Android and normal Java
This commit is contained in:
parent
742c59a7c7
commit
a9307693a6
4 changed files with 155 additions and 0 deletions
38
java/src/com/zerotier/one/JavaFileProvider.java
Normal file
38
java/src/com/zerotier/one/JavaFileProvider.java
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
package com.zerotier.one;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class JavaFileProvider implements DataStoreFileProvider {
|
||||
private String _path;
|
||||
|
||||
public JavaFileProvider(String path) {
|
||||
this._path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileInputStream getInputFileStream(String name)
|
||||
throws FileNotFoundException {
|
||||
File f = new File(_path + File.pathSeparator + name);
|
||||
return new FileInputStream(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileOutputStream getOutputFileStream(String name)
|
||||
throws FileNotFoundException {
|
||||
File f = new File(_path + File.pathSeparator + name);
|
||||
return new FileOutputStream(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFile(String name) throws IOException {
|
||||
File f = new File(_path + File.pathSeparator + name);
|
||||
boolean success = f.delete();
|
||||
if(!success) {
|
||||
throw new IOException("Unable to delete file: " + _path + File.pathSeparator + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue