turned back handling of map-writing into kelondro because of possible bug for testing

see http://www.yacy-forum.de/viewtopic.php?p=21560#21560
please re-test

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2119 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent e656a00b74
commit 74a78ebd78

@ -192,6 +192,37 @@ abstract class kelondroAbstractRA implements kelondroRA {
} }
} }
public void writeMap(final Map map, final String comment) throws IOException {
this.seek(0);
writeLine("# " + comment);
final Iterator iter = map.entrySet().iterator();
Map.Entry entry;
while (iter.hasNext()) {
entry = (Map.Entry) iter.next();
write(((String) entry.getKey()).getBytes());
write((byte) '=');
writeLine((String) entry.getValue());
}
writeLine("# EOF");
}
public Map readMap() throws IOException {
this.seek(0);
final TreeMap map = new TreeMap();
String line;
int pos;
while ((line = readLine()) != null) { // very slow readLine????
line = line.trim();
if (line.equals("# EOF")) return map;
if ((line.length() == 0) || (line.charAt(0) == '#')) continue;
pos = line.indexOf("=");
if (pos < 0) continue;
map.put(line.substring(0, pos), line.substring(pos + 1));
}
return map;
}
/*
public void writeMap(final Map map, final String comment) throws IOException { public void writeMap(final Map map, final String comment) throws IOException {
this.seek(0); this.seek(0);
final Iterator iter = map.entrySet().iterator(); final Iterator iter = map.entrySet().iterator();
@ -214,6 +245,7 @@ abstract class kelondroAbstractRA implements kelondroRA {
write(new String(sb).getBytes()); write(new String(sb).getBytes());
} }
public Map readMap() throws IOException { public Map readMap() throws IOException {
this.seek(0); this.seek(0);
byte[] b = readFully(); byte[] b = readFully();
@ -231,6 +263,7 @@ abstract class kelondroAbstractRA implements kelondroRA {
} }
return map; return map;
} }
*/
/** /**
* this does not write the content to the see position * this does not write the content to the see position

Loading…
Cancel
Save