Author: pwang
Date: 2012-06-05 16:49:03 -0700 (Tue, 05 Jun 2012)
New Revision: 29473
Added:
csplugins/trunk/ucsd/pwang/jActiveModules-impl/src/main/java/csplugins/jActiveModules/util/Util.java
Log:
Original creation
Added:
csplugins/trunk/ucsd/pwang/jActiveModules-impl/src/main/java/csplugins/jActiveModules/util/Util.java
===================================================================
---
csplugins/trunk/ucsd/pwang/jActiveModules-impl/src/main/java/csplugins/jActiveModules/util/Util.java
(rev 0)
+++
csplugins/trunk/ucsd/pwang/jActiveModules-impl/src/main/java/csplugins/jActiveModules/util/Util.java
2012-06-05 23:49:03 UTC (rev 29473)
@@ -0,0 +1,66 @@
+package csplugins.jActiveModules.util;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Writer;
+import java.util.ArrayList;
+
+import csplugins.jActiveModules.ActiveModulesUI;
+
+public class Util {
+
+ public static File getFileFromFar(String fileNameInJar){
+
+ File returnFile = null;
+
+ // Get the file contents from Jar
+ ArrayList<String> list = new ArrayList<String>();
+
+ BufferedReader bf = null;
+ String line;
+
+ try {
+ bf = new BufferedReader(new
InputStreamReader(ActiveModulesUI.class.getResourceAsStream("/"+fileNameInJar)
));
+ while (null != (line = bf.readLine())) {
+ list.add(line);
+ }
+ }
+ catch (IOException e){
+ }
+ finally {
+ try {
+ if (bf != null) bf.close();
+ }
+ catch (IOException e) {
+ }
+ }
+
+ if (list.size()==0){
+ return null;
+ }
+
+ // output the file content to a tmp file
+ Writer output;
+ try {
+ returnFile = File.createTempFile("jActiveModules_vs",
".props", new File(System.getProperty("java.io.tmpdir")));
+ returnFile.deleteOnExit();
+
+ //use buffering
+ output = new BufferedWriter(new FileWriter(returnFile));
+ //FileWriter always assumes default encoding is OK!
+ for (int i=0; i< list.size(); i++){
+ output.write( list.get(i)+ "\n");
+ }
+ output.close();
+ }
+ catch(IOException ioe){
+ ioe.printStackTrace();
+ }
+
+ return returnFile;
+ }
+}
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.