Revision: 2377
http://sourceforge.net/p/swingme/code/2377
Author: yuranet
Date: 2019-06-20 11:27:02 +0000 (Thu, 20 Jun 2019)
Log Message:
-----------
allow writers/readers for csv loader
Modified Paths:
--------------
UtilME/src/net/yura/mobile/io/CSVUtil.java
UtilME/src/net/yura/mobile/io/JSONUtil.java
Modified: UtilME/src/net/yura/mobile/io/CSVUtil.java
===================================================================
--- UtilME/src/net/yura/mobile/io/CSVUtil.java 2019-05-28 11:03:08 UTC (rev 2376)
+++ UtilME/src/net/yura/mobile/io/CSVUtil.java 2019-06-20 11:27:02 UTC (rev 2377)
@@ -5,6 +5,7 @@
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
+import java.io.Reader;
import java.io.Writer;
import java.util.Vector;
import net.yura.mobile.logging.Logger;
@@ -25,12 +26,14 @@
public abstract String getValueAt(Object obj, int c);
+ public void load(InputStream inputStream) throws IOException {
+ load(new InputStreamReader(inputStream));
+ }
+
// i took something when i wrote this, it was shiny and a powder
// makes for some crazy code, but at least it works
- public void load(InputStream inputStream) throws IOException {
+ public void load(Reader inputStreamTxt) throws IOException {
- InputStreamReader inputStreamTxt = new InputStreamReader(inputStream);
-
boolean inside=false;
char how=0;
int count=0;
@@ -102,24 +105,19 @@
//buf.append(ex.toString());
//}
finally {
-
try { if (inputStreamTxt!=null) inputStreamTxt.close(); }
catch(IOException ex) { Logger.info(null, ex); }
-
- try {if (inputStream!=null) inputStream.close(); }
- catch(IOException ex) { Logger.info(null, ex); }
}
}
-
public void store(OutputStream out, Vector objects,int count) throws IOException {
+ store(new OutputStreamWriter(out), objects, count);
+ }
- Writer writer = null;
+ public void store(Writer writer, Vector objects,int count) throws IOException {
try {
- writer = new OutputStreamWriter(out);
-
for (int a=0;a<objects.size();a++) {
Object obj = objects.elementAt(a);
@@ -161,12 +159,8 @@
}
}
finally {
-
try { if (writer!=null) writer.close(); }
catch(IOException ex) { Logger.info(null, ex); }
-
- try { if (out!=null) out.close(); }
- catch(IOException ex) { Logger.info(null, ex); }
}
}
}
Modified: UtilME/src/net/yura/mobile/io/JSONUtil.java
===================================================================
--- UtilME/src/net/yura/mobile/io/JSONUtil.java 2019-05-28 11:03:08 UTC (rev 2376)
+++ UtilME/src/net/yura/mobile/io/JSONUtil.java 2019-06-20 11:27:02 UTC (rev 2377)
@@ -18,6 +18,7 @@
/**
* @author Yura Mamyrin
+ * WARNING: this file uses Hashtable, that does NOT allow null values!
*/
public class JSONUtil {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|