public override void run() { try { java.io.InputStreamReader isr = new java.io.InputStreamReader(_is); java.io.BufferedReader br = new java.io.BufferedReader(isr); String line=null; while ( (line = br.readLine()) != null) { Debug.WriteLine(_type + ">" + line); } } catch (Exception ex) { Debug.WriteLine (ex); } }
static string InternalGetSDKVersion() { var version = ""; var w = ""; try { // by now we have webclient? // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201412/20141207 var url = new java.net.URL(SDKVersionLocation); HttpURLConnection con = (HttpURLConnection)url.openConnection(); int CONNECT_TIMEOUT_MILL = 2000; int READ_TIMEOUT_MILL = 900; con.setConnectTimeout(CONNECT_TIMEOUT_MILL); con.setReadTimeout(READ_TIMEOUT_MILL); var i = new java.io.InputStreamReader(con.getInputStream(), "UTF-8"); var reader = new java.io.BufferedReader(i); // can't we just read to the end? var line = reader.readLine(); while (line != null) { w += line; w += "\n"; line = reader.readLine(); } reader.close(); } catch { // oops } //Log.wtf("HttpURLConnection", w); if (w.Length > 0) { var value = w; var offset = 0; var i = ((java.lang.String)(object)value).indexOf("version=\"", offset) + "version=\"".Length; var j = ((java.lang.String)(object)value).indexOf("\"", i); var ii = ((java.lang.String)(object)value).indexOf("version=\"", j) + "version=\"".Length; var jj = ((java.lang.String)(object)value).indexOf("\"", ii); version = ((java.lang.String)(object)value).substring(ii, jj); } return version; }
static string InternalGetSDKVersion() { var version = ""; var w = ""; try { // by now we have webclient? // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201412/20141207 var url = new java.net.URL(SDKVersionLocation); HttpURLConnection con = (HttpURLConnection)url.openConnection(); int CONNECT_TIMEOUT_MILL = 2000; int READ_TIMEOUT_MILL = 900; con.setConnectTimeout(CONNECT_TIMEOUT_MILL); con.setReadTimeout(READ_TIMEOUT_MILL); var i = new java.io.InputStreamReader(con.getInputStream(), "UTF-8"); var reader = new java.io.BufferedReader(i); // can't we just read to the end? var line = reader.readLine(); while (line != null) { w += line; w += "\n"; line = reader.readLine(); } reader.close(); } catch { // oops } //Log.wtf("HttpURLConnection", w); if (w.Length > 0) { var value = w; var offset = 0; var i = ((java.lang.String)(object) value).indexOf("version=\"", offset) + "version=\"".Length; var j = ((java.lang.String)(object) value).indexOf("\"", i); var ii = ((java.lang.String)(object) value).indexOf("version=\"", j) + "version=\"".Length; var jj = ((java.lang.String)(object) value).indexOf("\"", ii); version = ((java.lang.String)(object) value).substring(ii, jj); } return(version); }
public override void run() { try { java.io.InputStreamReader isr = new java.io.InputStreamReader(_is); java.io.BufferedReader br = new java.io.BufferedReader(isr); String line = null; while ((line = br.readLine()) != null) { Debug.WriteLine(_type + ">" + line); } } catch (Exception ex) { Debug.WriteLine(ex); } }
public static Instances LoadInstances(string fileName) { lock (m_lockObject) { if (!fileName.Contains("\\")) { fileName = string.Format("{0}\\{1}", TestParameters.BaseDir, fileName); } var fr = new java.io.FileReader(fileName); var br = new java.io.BufferedReader(fr); Instances instances = new Instances(br); br.close(); fr.close(); instances.setClassIndex(instances.numAttributes() - 1); return(instances); } }
public EventLogTags(java.io.BufferedReader arg0) : base(global::MonoJavaBridge.JNIEnv.ThreadEnv) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; global::MonoJavaBridge.JniLocalHandle handle = @__env.NewObject(android.util.EventLogTags.staticClass, global::android.util.EventLogTags._EventLogTags8517, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)); Init(@__env, handle); }
// http://zadjhu.blogspot.com/2013/03/android-jellybean-does-not-allocate.html public void ShellAsync(string e, Action<string> y) { // http://a3nm.net/blog/android_cli.html #if Android // http://www.android.pk/blog/general/launch-app-through-adb-shell/ // am start -a android.intent.action.MAIN -n com.android.settings/.Settings // am start tel:210-385-0098 // am start -a android.intent.action.CALL tel:245007 // am start -a android.intent.action.SENDTO "sms:5245007" -e "sms_body" "heyy" && input keyevent 22 && input keyevent 66 // am start -a android.intent.action.SENDTO -d sms:1234567890 --es sms_body ohai --ez exit_on_sent true // am start -a android.intent.action.SENDTO -d smsto:245007 --es sms_body ":*" --ez exit_on_sent true && am start -a android.intent.action.SENDTO -d sms:5245007 --es sms_body ":*" --ez exit_on_sent true && input keyevent 22 && input keyevent 66 // pm list packages // pm list packages -f //http://stackoverflow.com/questions/11201659/android-adb-shell-dumpsys-tool // am start -S -e sms_body 'your message body' \ //-e address receiver -t 'vnd.android-dir/mms-sms' \ //com.android.mms/com.android.mms.ui.ComposeMessageActivity \ //&& adb shell input keyevent 66 //am start -n com.google.android.youtube/.PlayerActivity -d http://www.youtube.com/watch?v=MTT-crZBB0k // http://stackoverflow.com/questions/7095470/android-read-send-text-messages-on-ubuntu // System.InvalidOperationException: Sequence contains more than one element //at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source) //at jsc.Languages.Java.JavaCompiler.GetArrayEnumeratorType() in x:\jsc.internal.svn\compiler\jsc\Languages\Java\JavaCompiler.overrride.cs:line 52 //at jsc.Languages.Java.JavaCompiler.GetImportTypes(Type t, Boolean bExcludeJavaLang) in x:\jsc.internal.svn\compiler\jsc\Languages\Java\JavaCompiler.WriteImportTypes.cs:line 363 //at jsc.Languages.Java.JavaCompiler.WriteImportTypes(Type ContextType) in x:\jsc.internal.svn\compiler\jsc\Languages\Java\JavaCompiler.WriteImportTypes.cs:line 22 //at jsc.Languages.Java.JavaCompiler.CompileType(Type z) in x:\jsc.internal.svn\compiler\jsc\Languages\Java\JavaCompiler.CompileType.cs:line 43 //at jsc.Languages.CompilerJob.<>c__DisplayClass1a.<CompileJava>b__17(Type xx) in x:\jsc.internal.svn\compiler\jsc\Languages\Java\CompilerJob.cs:line 120 // IsArrayEnumerator: ScriptCoreLib.Shared.BCLImplementation.System.__SZArrayEnumerator`1, ScriptCoreLibAndroid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null //IsArrayEnumerator: ScriptCoreLib.Shared.BCLImplementation.System.__SZArrayEnumerator`1, ScriptCoreLibJava, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null try { // http://stackoverflow.com/questions/9062182/android-icmp-ping // https://gist.github.com/micahasmith/5084997 var p = new java.lang.ProcessBuilder(new[] { "sh" }).redirectErrorStream(true).start(); var os = new java.io.DataOutputStream(p.getOutputStream()); //os.writeBytes(e + '\n'); os.writeBytes(e + "\n"); os.flush(); // Close the terminal os.writeBytes("exit\n"); os.flush(); // read ping replys var reader = new java.io.BufferedReader(new java.io.InputStreamReader(p.getInputStream())); string line = reader.readLine(); while (line != null) { y(line); line = reader.readLine(); } } catch (System.Exception ex) { y("AndroidShellAsync error: " + new { ex.Message }); } #else y("ShellAsync not implemented."); #endif }
public static JmolCrystal Read(string path) { var crystal = new JmolCrystal(); using (StreamReader sr = new StreamReader(path)) { crystal.Cif = sr.ReadToEnd(); } java.io.BufferedReader buffReader = new java.io.BufferedReader(new java.io.FileReader(path)); java.util.Map parameters = new java.util.Hashtable(); var ascr = org.jmol.adapter.smarter.SmarterJmolAdapter.staticGetAtomSetCollectionReader(path, null, buffReader, parameters); if (ascr is org.jmol.adapter.smarter.AtomSetCollectionReader) { var asc = org.jmol.adapter.smarter.SmarterJmolAdapter.staticGetAtomSetCollection((ascr as org.jmol.adapter.smarter.AtomSetCollectionReader)) as org.jmol.adapter.smarter.AtomSetCollection; if (asc != null) { var auxInfo = new Dictionary <string, string>(); if (asc.atoms != null) { crystal.Atoms = asc.atoms.ToArray().Where(a => a != null).Select(a => new JmolAtom() { AtomName = a.atomName, Symbol = a.elementSymbol, X = a.x, Y = a.y, Z = a.z }).ToList(); } if (asc.bonds != null) { crystal.Bonds = asc.bonds.ToArray().Where(b => b != null).Select(b => new JmolBond() { AtomIndex1 = b.atomIndex1, AtomIndex2 = b.atomIndex2 }).ToList(); } for (var i = 0; i < asc.atomSetAuxiliaryInfo.Length; i++) { var info = asc.atomSetAuxiliaryInfo[i]; if (info != null) { var keys = info.keySet().toArray(); for (var i2 = 0; i2 < keys.Length; i2++) { var key = keys[i2]; var val = info.get(key); if (val == null) { continue; } if (key.Equals("chemicalName")) { crystal.ChemicalName = val.ToString(); } else if (key.Equals("formula")) { crystal.ChemicalFormula = val.ToString(); } else if (key.Equals("unitCellParams")) { var array = val as Array; if (array.Length >= 6) { crystal.LengthA = Convert.ToDouble(array.GetValue(0)); crystal.LengthB = Convert.ToDouble(array.GetValue(1)); crystal.LengthC = Convert.ToDouble(array.GetValue(2)); crystal.Alpha = Convert.ToDouble(array.GetValue(3)); crystal.Beta = Convert.ToDouble(array.GetValue(4)); crystal.Gamma = Convert.ToDouble(array.GetValue(5)); } } else if (val is java.lang.Integer || val is java.lang.Boolean || val is System.String) { if (string.IsNullOrEmpty(val.ToString()) || val.ToString().Equals("null") || val.ToString().Equals("?")) { continue; } crystal.AuxInfo[key.ToString()] = val.ToString(); } } } } } } return(crystal); }