Revision 1764
Added by Jing Tao over 21 years ago
src/edu/ucsb/nceas/metacat/EmlSAXHandler.java | ||
---|---|---|
34 | 34 |
import java.io.File; |
35 | 35 |
import java.io.FileReader; |
36 | 36 |
import java.io.FileWriter; |
37 |
import java.io.Reader; |
|
37 | 38 |
import java.io.StringReader; |
38 | 39 |
import java.util.Stack; |
39 | 40 |
import java.util.Vector; |
... | ... | |
2196 | 2197 |
/* In eml2, the inline data wouldn't store in db, it store in file system |
2197 | 2198 |
* The db stores file name(without path). |
2198 | 2199 |
*/ |
2199 |
public static String readInlineDataFromFileSystem(String fileName)
|
|
2200 |
public static Reader readInlineDataFromFileSystem(String fileName)
|
|
2200 | 2201 |
throws McdbException |
2201 | 2202 |
{ |
2202 |
String data = null; |
|
2203 |
//BufferedReader stringReader = null; |
|
2204 |
FileReader fileReader = null; |
|
2203 | 2205 |
String path = MetaCatUtil.getOption("inlinedatafilepath"); |
2204 | 2206 |
// the new file name will look like path/docid.rev.2 |
2205 | 2207 |
File inlineDataDirectory = new File(path); |
2206 | 2208 |
File dataFile = new File(inlineDataDirectory, fileName); |
2207 | 2209 |
try |
2208 | 2210 |
{ |
2209 |
FileReader fileReader = new FileReader(dataFile); |
|
2210 |
BufferedReader stringReader = new BufferedReader(fileReader); |
|
2211 |
// read first line of data |
|
2212 |
String tmp = stringReader.readLine(); |
|
2213 |
// pass first line data to data varible |
|
2214 |
data = tmp; |
|
2215 |
// at the end tmp will be null |
|
2216 |
while (tmp != null) |
|
2217 |
{ |
|
2218 |
// read a new line |
|
2219 |
tmp = stringReader.readLine(); |
|
2220 |
// append new line to data |
|
2221 |
if (tmp != null) |
|
2222 |
{ |
|
2223 |
data = data+tmp; |
|
2224 |
} |
|
2225 |
} |
|
2226 |
|
|
2211 |
fileReader = new FileReader(dataFile); |
|
2212 |
//stringReader = new BufferedReader(fileReader); |
|
2227 | 2213 |
} |
2228 | 2214 |
catch (Exception e) |
2229 | 2215 |
{ |
2230 | 2216 |
throw new McdbException(e.getMessage()); |
2231 | 2217 |
} |
2232 |
MetaCatUtil.debugMessage("the inline data retrieve from file: "+data, 50);
|
|
2233 |
return data;
|
|
2218 |
// return stringReader;
|
|
2219 |
return fileReader;
|
|
2234 | 2220 |
} |
2235 | 2221 |
|
2236 | 2222 |
/* Delete relations */ |
Also available in: Unified diff
Using reader replacing string to read inline data.