FileInputSource.java
1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.commons.io.FileUtils
*/
package com.day.jcr.vault.util;
import com.day.jcr.vault.fs.api.VaultInputSource;
import com.day.jcr.vault.util.LineInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.io.FileUtils;
public class FileInputSource
extends VaultInputSource {
private final File file;
private byte[] lineSeparator;
public FileInputSource(File file) {
super(file.getPath());
this.file = file;
}
public void setLineSeparator(byte[] lineSeparator) {
this.lineSeparator = lineSeparator;
}
public InputStream getByteStream() {
try {
if (this.lineSeparator != null) {
return new LineInputStream(new FileInputStream(this.file), this.lineSeparator);
}
return FileUtils.openInputStream((File)this.file);
}
catch (IOException e) {
return null;
}
}
public long getContentLength() {
return this.file.length();
}
public long getLastModified() {
return this.file.lastModified();
}
public void discard() {
this.file.delete();
this.file.deleteOnExit();
}
}