public static bool rename0(object _this, java.io.File f1, java.io.File f2) { throw new NotImplementedException(); // try //{ // new FileInfo(GetPathFromFile(f1)).MoveTo(GetPathFromFile(f2)); // return true; //} //catch (SecurityException) //{ //} //catch (ArgumentException) //{ //} //catch (UnauthorizedAccessException) //{ //} //catch (IOException) //{ //} //catch (NotSupportedException) //{ //} //return false; }
public virtual void run() { Exception exception; try { ((Window) main.access\u0024000()).pack(); ((Window) main.access\u0024000()).setVisible(true); this.val\u0024monitor.setProgress(750); this.val\u0024monitor.setNote("Loading From Save"); File.__\u003Cclinit\u003E(); File file = new File((string) main.access\u0024000().getPrefs().__\u003C\u003EsaveFile.getValue()); if (file.exists()) main.access\u0024000().load(file.getPath()); this.val\u0024monitor.setProgress(1000); return; } catch (Exception ex) { int num = 0; M0 m0 = ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num); if (m0 == null) throw; else exception = (Exception) m0; } Throwable.instancehelper_printStackTrace((Exception) exception); System.exit(1); }
public static long getSpace0(object _this, java.io.File f, int t) { #if !FIRST_PASS long freeAvailable; long total; long totalFree; StringBuilder volname = new StringBuilder(256); if (GetVolumePathName(GetPathFromFile(f), volname, volname.Capacity) != 0 && GetDiskFreeSpaceEx(volname.ToString(), out freeAvailable, out total, out totalFree) != 0) { switch (t) { case java.io.FileSystem.SPACE_TOTAL: return(total); case java.io.FileSystem.SPACE_FREE: return(totalFree); case java.io.FileSystem.SPACE_USABLE: return(freeAvailable); } } #endif return(0); }
/// <summary> /// /// </summary> /// <param name="filePath"></param> /// <param name="password">Optional password to open the file.</param> /// <returns></returns> public string GetHtmlContent(string filePath, String password) { try { Logger.DebugFormat("GetHtmlContent for filePath: {0}", filePath); var file = new File(filePath); return this.Extract((Func<Metadata, InputStream>)(metadata => { Logger.DebugFormat("Extract metadata for {0}", filePath); if (!String.IsNullOrEmpty(password)) { metadata.add("org.apache.tika.parser.pdf.password", password); } var tikaInputStream = TikaInputStream.get(file, metadata); Logger.DebugFormat("Return tikaInputStream for {0}", filePath); return (InputStream)tikaInputStream; })); } catch (System.Exception ex) { Logger.ErrorFormat(ex, "Error on GetHtmlContent for {0}", filePath); throw new TextExtractionException( StringExtrensions.ToFormat( "Extraction of text from the file '{0}' failed.", new object[] { (object)filePath } ), ex ); } }
public static long getLength(object _this, java.io.File f) { throw new NotImplementedException(); // try //{ // string path = GetPathFromFile(f); // if (VirtualFileSystem.IsVirtualFS(path)) // { // return VirtualFileSystem.GetLength(path); // } // return new FileInfo(path).Length; //} //catch (SecurityException) //{ //} //catch (ArgumentException) //{ //} //catch (UnauthorizedAccessException) //{ //} //catch (IOException) //{ //} //catch (NotSupportedException) //{ //} //return 0; }
public static bool createDirectory(object _this, java.io.File f) { try { string path = GetPathFromFile(f); DirectoryInfo parent = Directory.GetParent(path); if (parent == null || !Directory.Exists(parent.FullName) || Directory.Exists(path)) { return(false); } return(Directory.CreateDirectory(path) != null); } catch (SecurityException) { } catch (ArgumentException) { } catch (UnauthorizedAccessException) { } catch (IOException) { } catch (NotSupportedException) { } return(false); }
public static bool setLastModifiedTime(object _this, java.io.File f, long time) { throw new NotImplementedException(); //try //{ // new FileInfo(GetPathFromFile(f)).LastWriteTime = JavaLongTimeToDateTime(time); // return true; //} //catch (SecurityException) //{ //} //catch (ArgumentException) //{ //} //catch (UnauthorizedAccessException) //{ //} //catch (IOException) //{ //} //catch (NotSupportedException) //{ //} //return false; }
internal static bool EmbedPDFAttachment(List <PDFAttachmentItem> attachments, PDDocument doc) { bool flag; try { PDEmbeddedFilesNameTreeNode pDEmbeddedFilesNameTreeNode = new PDEmbeddedFilesNameTreeNode(); List arrayList = new ArrayList(); foreach (PDFAttachmentItem attachment in attachments) { PDComplexFileSpecification pDComplexFileSpecification = new PDComplexFileSpecification(); pDComplexFileSpecification.setFile(System.IO.Path.GetFileName(attachment.filePath)); java.io.File file = new java.io.File(attachment.filePath); byte[] numArray = Files.readAllBytes(file.toPath()); PDEmbeddedFile pDEmbeddedFile = new PDEmbeddedFile(doc, new ByteArrayInputStream(numArray)); pDEmbeddedFile.setSize((int)numArray.Length); pDEmbeddedFile.setCreationDate(new GregorianCalendar()); pDComplexFileSpecification.setEmbeddedFile(pDEmbeddedFile); PDEmbeddedFilesNameTreeNode pDEmbeddedFilesNameTreeNode1 = new PDEmbeddedFilesNameTreeNode(); pDEmbeddedFilesNameTreeNode1.setNames(Collections.singletonMap(attachment.filePath, pDComplexFileSpecification)); arrayList.@add(pDEmbeddedFilesNameTreeNode1); } pDEmbeddedFilesNameTreeNode.setKids(arrayList); PDDocumentNameDictionary pDDocumentNameDictionary = new PDDocumentNameDictionary(doc.getDocumentCatalog()); pDDocumentNameDictionary.setEmbeddedFiles(pDEmbeddedFilesNameTreeNode); doc.getDocumentCatalog().setNames(pDDocumentNameDictionary); flag = true; } catch (Exception exception1) { Exception exception = exception1; throw new PDFToolkitException(exception.Message, exception); } return(flag); }
public static bool setReadOnly(object _this, java.io.File f) { throw new NotImplementedException(); //try //{ // FileInfo fileInfo = new FileInfo(GetPathFromFile(f)); // fileInfo.Attributes |= FileAttributes.ReadOnly; // return true; //} //catch (SecurityException) //{ //} //catch (ArgumentException) //{ //} //catch (UnauthorizedAccessException) //{ //} //catch (IOException) //{ //} //catch (NotSupportedException) //{ //} //return false; }
//[SecuritySafeCritical] public static long getSpace0(object _this, java.io.File f, int t) { #if !FIRST_PASS throw new NotImplementedException(); #endif return(0); }
public static long getLength(object _this, java.io.File f) { try { string path = GetPathFromFile(f); if (VirtualFileSystem.IsVirtualFS(path)) { return(VirtualFileSystem.GetLength(path)); } return(new FileInfo(path).Length); } catch (SecurityException) { } catch (ArgumentException) { } catch (UnauthorizedAccessException) { } catch (IOException) { } catch (NotSupportedException) { } return(0); }
public static long getSpace0(object _this, java.io.File f, int t) { const int SPACE_TOTAL = 0; const int SPACE_FREE = 1; const int SPACE_USABLE = 2; long freeAvailable; long total; long totalFree; if (GetDiskFreeSpaceEx(GetPathFromFile(f), out freeAvailable, out total, out totalFree) != 0) { switch (t) { case SPACE_TOTAL: return(total); case SPACE_FREE: return(totalFree); case SPACE_USABLE: return(freeAvailable); } } return(0); }
public static string[] list(object _this, java.io.File f) { throw new NotImplementedException(); //try //{ // string path = GetPathFromFile(f); // if (VirtualFileSystem.IsVirtualFS(path)) // { // return VirtualFileSystem.List(path); // } // string[] l = Directory.GetFileSystemEntries(path); // for (int i = 0; i < l.Length; i++) // { // int pos = l[i].LastIndexOf(Path.DirectorySeparatorChar); // if (pos >= 0) // { // l[i] = l[i].Substring(pos + 1); // } // } // return l; //} //catch (ArgumentException) //{ //} //catch (IOException) //{ //} //catch (UnauthorizedAccessException) //{ //} //catch (NotSupportedException) //{ //} //return null; }
public static bool createDirectory(object _this, java.io.File f) { throw new NotImplementedException(); //try //{ // string path = GetPathFromFile(f); // DirectoryInfo parent = Directory.GetParent(path); // if (parent == null || // !Directory.Exists(parent.FullName) || // Directory.Exists(path)) // { // return false; // } // return Directory.CreateDirectory(path) != null; //} //catch (SecurityException) //{ //} //catch (ArgumentException) //{ //} //catch (UnauthorizedAccessException) //{ //} //catch (IOException) //{ //} //catch (NotSupportedException) //{ //} //return false; }
public static string[] list(object _this, java.io.File f) { try { string path = GetPathFromFile(f); if (VirtualFileSystem.IsVirtualFS(path)) { return(VirtualFileSystem.List(path)); } string[] l = Directory.GetFileSystemEntries(path); for (int i = 0; i < l.Length; i++) { int pos = l[i].LastIndexOf(Path.DirectorySeparatorChar); if (pos >= 0) { l[i] = l[i].Substring(pos + 1); } } return(l); } catch (ArgumentException) { } catch (IOException) { } catch (UnauthorizedAccessException) { } catch (NotSupportedException) { } return(null); }
public static long getLastModifiedTime(object _this, java.io.File f) { try { DateTime dt = File.GetLastWriteTime(GetPathFromFile(f)); if (dt.ToFileTime() == 0) { return(0); } else { return(DateTimeToJavaLongTime(dt)); } } catch (UnauthorizedAccessException) { } catch (ArgumentException) { } catch (IOException) { } catch (NotSupportedException) { } return(0); }
public static bool setReadOnly(object _this, java.io.File f) { try { FileInfo fileInfo = new FileInfo(GetPathFromFile(f)); fileInfo.Attributes |= FileAttributes.ReadOnly; return(true); } catch (SecurityException) { } catch (ArgumentException) { } catch (UnauthorizedAccessException) { } catch (IOException) { } catch (NotSupportedException) { } return(false); }
public virtual File newFile(string fileName) { File.__\u003Cclinit\u003E(); File file = new File(this.folder, fileName); file.createNewFile(); return file; }
public static Object LoadFromFile(java.io.File f, string baseUri, org.openrdf.rio.RDFFormat rdff) { Object obj; if (rdff == dotSesameFormats.RDFFormat.N3) { obj = new Graph(); if (baseUri != null) { ((IGraph)obj).BaseUri = new Uri(baseUri); } FileLoader.Load((IGraph)obj, f.getPath(), new Notation3Parser()); } else if (rdff == dotSesameFormats.RDFFormat.NTRIPLES) { obj = new Graph(); if (baseUri != null) { ((IGraph)obj).BaseUri = new Uri(baseUri); } FileLoader.Load((IGraph)obj, f.getPath(), new NTriplesParser()); } else if (rdff == dotSesameFormats.RDFFormat.RDFXML) { obj = new Graph(); if (baseUri != null) { ((IGraph)obj).BaseUri = new Uri(baseUri); } FileLoader.Load((IGraph)obj, f.getPath(), new RdfXmlParser()); } else if (rdff == dotSesameFormats.RDFFormat.TRIG) { obj = new TripleStore(); TriGParser trig = new TriGParser(); trig.Load((ITripleStore)obj, new StreamParams(f.getPath())); } else if (rdff == dotSesameFormats.RDFFormat.TRIX) { obj = new TripleStore(); TriXParser trix = new TriXParser(); trix.Load((ITripleStore)obj, new StreamParams(f.getPath())); } else if (rdff == dotSesameFormats.RDFFormat.TURTLE) { obj = new Graph(); if (baseUri != null) { ((IGraph)obj).BaseUri = new Uri(baseUri); } FileLoader.Load((IGraph)obj, f.getPath(), new TurtleParser()); } else { throw new RdfParserSelectionException("The given Input Format is not supported by dotNetRDF"); } return(obj); }
public Generator(Properties properties, File file) { base.\u002Ector(); Generator generator = this; this.properties = properties; this.file = file; this.writer = (PrintWriter) null; }
public Generator(Properties properties, PrintWriter writer) { base.\u002Ector(); Generator generator = this; this.properties = properties; this.file = (File) null; this.writer = writer; }
private MaxHistory([In] File obj0) { base.\u002Ector(); MaxHistory maxHistory = this; this.fDurations = (Map) new HashMap(); this.fFailureTimestamps = (Map) new HashMap(); this.fHistoryStore = obj0; }
private static string GetPathFromFile(java.io.File file) { #if FIRST_PASS return(null); #else return(file.getPath()); #endif }
public void File_list( string path, ystring ydirectory, ystring yfile, string sskip = "0", string stake = "10", ystring done = null) { #if Android var DIRECTORY_DCIM = global::android.os.Environment.DIRECTORY_DCIM; path = global::android.os.Environment.getExternalStoragePublicDirectory(DIRECTORY_DCIM).getAbsolutePath(); path += "/Camera"; var f = new File(path); //Caused by: java.lang.Runtim //eException: Implement IComparable for java.lang.Long vs java.lang.Long // at ScriptCoreLibJava.BCLImplementation.System.Collections.__Comparer.Compare(__Comparer.java:136) var a = f.listFiles().Where(k => k.getName().EndsWith(".jpg")).OrderByDescending(k => (double)k.lastModified()).ToArray(); //foreach (var item in a) //{ // if (new File(path + "/" + item).isDirectory()) // ydirectory(path + "/" + item); //} int skip = int.Parse(sskip); int take = int.Parse(stake); foreach (var item in a) { if (skip > 0) { skip--; } else { if (take > 0) { take--; yfile(path + "/" + item.getName()); } else { break; } } } #endif if (done != null) done(""); }
public List <double> testMLPUsingWeka(string[] attributeArray, string[] classNames, double[] dataValues, string classHeader, string defaultclass, string modelName, int hiddelLayers = 7, double learningRate = 0.03, double momentum = 0.4, int decimalPlaces = 2, int trainingTime = 1000) { java.util.ArrayList classLabel = new java.util.ArrayList(); foreach (string className in classNames) { classLabel.Add(className); } weka.core.Attribute classHeaderName = new weka.core.Attribute(classHeader, classLabel); java.util.ArrayList attributeList = new java.util.ArrayList(); foreach (string attribute in attributeArray) { weka.core.Attribute newAttribute = new weka.core.Attribute(attribute); attributeList.Add(newAttribute); } attributeList.add(classHeaderName); weka.core.Instances data = new weka.core.Instances("TestInstances", attributeList, 0); data.setClassIndex(data.numAttributes() - 1); // Set instance's values for the attributes weka.core.Instance inst_co = new DenseInstance(data.numAttributes()); for (int i = 0; i < data.numAttributes() - 1; i++) { inst_co.setValue(i, dataValues.ElementAt(i)); } inst_co.setValue(classHeaderName, defaultclass); data.add(inst_co); java.io.File path = new java.io.File("/models/"); weka.classifiers.functions.MultilayerPerceptron clRead = loadModel(modelName, path); clRead.setHiddenLayers(hiddelLayers.ToString()); clRead.setLearningRate(learningRate); clRead.setMomentum(momentum); clRead.setNumDecimalPlaces(decimalPlaces); clRead.setTrainingTime(trainingTime); weka.filters.Filter myRandom = new weka.filters.unsupervised.instance.Randomize(); myRandom.setInputFormat(data); data = weka.filters.Filter.useFilter(data, myRandom); double classValue = clRead.classifyInstance(data.get(0)); double[] predictionDistribution = clRead.distributionForInstance(data.get(0)); List <double> predictionDistributions = new List <double>(); for (int predictionDistributionIndex = 0; predictionDistributionIndex < predictionDistribution.Count(); predictionDistributionIndex++) { string classValueString1 = classLabel.get(predictionDistributionIndex).ToString(); double prob = predictionDistribution[predictionDistributionIndex] * 100; predictionDistributions.Add(prob); } List <double> prediction = new List <double>(); prediction.Add(classValue); prediction.AddRange(predictionDistributions); return(prediction); }
public void Invoke(params string[] args) { try { // http://bigjavablog.blogspot.com/2008/08/load-jar-files-and-java-classes.html if (Method != null) { var main_args = new string[0]; this.Method.invoke(null, new object[] { main_args }); } else { /* We need and URL to load the jar file. */ URL u = new File(this.AssemblyPath).toURL(); /* Load jar file using URLClassLoader. */ URLClassLoader cl = new URLClassLoader(new URL[] { u }); if (NativeAssemblyPath != null) { var nc = cl.loadClass("jni.CPtrLibrary"); var ncf = nc.getField("LibraryPath"); ncf.set(null, NativeAssemblyPath); } var c = cl.loadClass(this.TypeName); foreach (var m in c.getMethods()) { if (m.getDeclaringClass() == c) { if (m.getName() == "main") { this.Method = m; var main_args = new string[0]; this.Method.invoke(null, new object[] { main_args }); } } } } } catch (csharp.ThrowableException ex) { var exo = (object)ex; Console.WriteLine("error!"); Console.WriteLine(ex.Message + " - " + ex.ToString()); ErrorHandler(exo); } }
public virtual bool accept(File dir) { if (dir.isDirectory() && this.acceptsDirectories()) return true; for (int index = 0; index < this.fileext.Length; ++index) { if (String.instancehelper_endsWith(dir.getName(), this.fileext[index])) return true; } return false; }
private void recordBtn_Click(object sender, EventArgs e) { if (setMode) { try { String filename = "Class" + LoginForm.classSec + "_kidWordAudio/test.wav"; recordBtn.Text = "STOP"; wavSource = new NAudio.Wave.WaveIn(); wavSource.WaveFormat = new NAudio.Wave.WaveFormat(44100, 1); wavSource.DataAvailable += new EventHandler <NAudio.Wave.WaveInEventArgs>(wavSource_DataAvail); wavSource.RecordingStopped += new EventHandler <NAudio.Wave.StoppedEventArgs>(wavSource_RecordingStop); wavFile = new NAudio.Wave.WaveFileWriter(filename, wavSource.WaveFormat); wavSource.StartRecording(); setMode = false; } catch (Exception) { throw; } } else { //When you press "STOP", it automatically compares wavSource.StopRecording(); String recordWAV_file = "Class" + LoginForm.classSec + "_kidWordAudio/test.wav"; String refWAV_file = "Class" + LoginForm.classSec + "_kidWordAudio/" + levels[curPos] + ";.wav"; java.io.File f1 = new java.io.File(recordWAV_file); java.io.File f2 = new java.io.File(refWAV_file); if (!f1.exists() || !f2.exists()) { MessageBox.Show("WARNING: One of the files might be missing!"); } else { float compute_Result = compareAudio(recordWAV_file, refWAV_file); if (compute_Result >= 10.0) { MessageBox.Show("Matched: " + compute_Result.ToString() + "\n You Win !"); } else { MessageBox.Show("Matched: " + compute_Result.ToString() + "\n Try Again !"); } } recordBtn.Text = "RECORD"; setMode = true; } }
public PlayerNBTManager(File file, string s, bool flag) { field_22099_b = new File(file, s); field_22099_b.mkdirs(); worldFile = new File(field_22099_b, "players"); if (flag) { worldFile.mkdirs(); } func_22098_f(); }
private static weka.classifiers.meta.Bagging loadBaggingModel(String name, java.io.File path) { weka.classifiers.meta.Bagging classifier; FileInputStream fis = new FileInputStream("..\\..\\..\\..\\libs\\models\\" + "models" + name + ".model"); ObjectInputStream ois = new ObjectInputStream(fis); classifier = (weka.classifiers.meta.Bagging)ois.readObject(); ois.close(); return(classifier); }
private static weka.classifiers.functions.SMO loadSMOModel(String name, java.io.File path) { // weka.classifiers.bayes.HMM .HMMEstimator.packageManagement.Package p=new ; weka.classifiers.functions.SMO classifier; FileInputStream fis = new FileInputStream(name); ObjectInputStream ois = new ObjectInputStream(fis); classifier = (weka.classifiers.functions.SMO)ois.readObject(); ois.close(); return(classifier); }
public bool accept(File file) { if (file.isDirectory()) { Matcher matcher = field_22214_a.matcher(file.getName()); return matcher.matches(); } else { return false; } }
/// <summary> /// 剪辑字体 /// </summary> /// <param name="subString">新字体文本信息</param> /// <param name="fontPathOri">原始字体路径</param> /// <param name="fontPathNew">新字体路径</param> public void ClipFont(string subsetString, string fontPathOri, string fontPathNew) { try { var localFileOri = new java.io.File(fontPathOri); var localFileNew = new java.io.File(fontPathNew); SubsetFontFile(subsetString, localFileOri, localFileNew); } catch (System.Exception ex) { throw new System.Exception(ex.Message); } }
protected internal virtual File performSelectFile(File selectedFile, int dialogType, bool appendExtension) { if (this.fileChooser == null) this.fileChooser = this.createFileChooser(); this.fileChooser.setSelectedFile(selectedFile); this.fileChooser.setDialogType(dialogType); if (this.fileChooser.showDialog(this.parent, (string) null) != 0) return (File) null; string @base = this.fileChooser.getSelectedFile().getAbsolutePath(); if (!StringUtils.endsWithIgnoreCase(@base, this.getFileExtension())) @base = new StringBuffer().append(@base).append(this.getFileExtension()).toString(); return new File(@base); }
public virtual IChunkLoader func_22092_a(WorldProvider worldprovider) { if (worldprovider is WorldProviderHell) { var file = new File(field_22099_b, "DIM-1"); file.mkdirs(); return new ChunkLoader(file, true); } else { return new ChunkLoader(field_22099_b, true); } }
public void File_list( string path, ystring ydirectory, ystring yfile, string sskip = "0", string stake = "10", ystring done = null) { var DIRECTORY_DCIM = android.os.Environment.DIRECTORY_DCIM; path = android.os.Environment.getExternalStoragePublicDirectory(DIRECTORY_DCIM).getAbsolutePath(); path += "/Camera"; var f = new File(path); var a = f.list(); foreach (var item in a) { if (new File(path + "/" + item).isDirectory()) ydirectory(path + "/" + item); } int skip = int.Parse(sskip); int take = int.Parse(stake); foreach (var item in a) { if (skip > 0) { skip--; } else { if (take > 0) { take--; if (new File(path + "/" + item).isFile()) yfile(path + "/" + item); } else { break; } } } done(""); }
public static int getBooleanAttributes(object _this, java.io.File f) { #if WINRT || false throw new NotImplementedException(); #else try { string path = GetPathFromFile(f); if (VirtualFileSystem.IsVirtualFS(path)) { return(VirtualFileSystem.GetBooleanAttributes(path)); } FileAttributes attr = File.GetAttributes(path); const int BA_EXISTS = 0x01; const int BA_REGULAR = 0x02; const int BA_DIRECTORY = 0x04; const int BA_HIDDEN = 0x08; int rv = BA_EXISTS; if ((attr & FileAttributes.Directory) != 0) { rv |= BA_DIRECTORY; } else { rv |= BA_REGULAR; } if ((attr & FileAttributes.Hidden) != 0) { rv |= BA_HIDDEN; } return(rv); } catch (ArgumentException) { } catch (UnauthorizedAccessException) { } catch (SecurityException) { } catch (NotSupportedException) { } catch (IOException) { } return(0); #endif }
public override IChunkLoader func_22092_a(WorldProvider worldprovider) { File file = func_22097_a(); if (worldprovider is WorldProviderHell) { var file1 = new File(file, "DIM-1"); file1.mkdirs(); return new McRegionChunkLoader(file1); } else { return new McRegionChunkLoader(file); } }
/*private void RegisterDecimalFormats(TestDriver driver, XPathCompiler xpc, XdmItem env, Environment environment) { * foreach (XdmItem decimalFormat in xpc.Evaluate("decimal-format", env)) { * DecimalFormatManager dfm = environment.xpathCompiler.getUnderlyingStaticContext().getDecimalFormatManager(); * * XdmNode formatElement = (XdmNode) decimalFormat; * String formatName = formatElement.getAttributeValue(new QName("name")); * StructuredQName formatQName = null; * if (formatName != null) { * if (formatName.indexOf(':') < 0) { * formatQName = new StructuredQName("", "", formatName); * } else { * try { * formatQName = StructuredQName.fromLexicalQName(formatName, false, true, Name11Checker.getInstance(), * new InscopeNamespaceResolver(formatElement.getUnderlyingNode())); * } catch (XPathException e) { * driver.println("**** Invalid QName as decimal-format name"); * formatQName = new StructuredQName("", "", "error-name"); * } * } * environment.paramDecimalDeclarations.append("declare decimal-format " + formatQName.getEQName() + " "); * } else { * environment.paramDecimalDeclarations.append("declare default decimal-format "); * } * DecimalSymbols symbols = (formatQName == null ? dfm.getDefaultDecimalFormat() : dfm.obtainNamedDecimalFormat(formatQName)); * symbols.setHostLanguage(Configuration.XQUERY); * for (XdmItem decimalFormatAtt : xpc.Evaluate("@* except @name", formatElement)) { * XdmNode formatAttribute = (XdmNode) decimalFormatAtt; * String property = formatAttribute.getNodeName().getLocalName(); * String value = formatAttribute.getStringValue(); * environment.paramDecimalDeclarations.append(property + "=\"" + value + "\" "); * try { * if (property.Equals("decimal-separator")) { * symbols.setDecimalSeparator(value); * } else if (property.Equals("grouping-separator")) { * symbols.setGroupingSeparator(value); * } else if (property.Equals("infinity")) { * symbols.setInfinity(value); * } else if (property.Equals("NaN")) { * symbols.setNaN(value); * } else if (property.Equals("minus-sign")) { * symbols.setMinusSign((value)); * } else if (property.Equals("percent")) { * symbols.setPercent((value)); * } else if (property.Equals("per-mille")) { * symbols.setPerMille((value)); * } else if (property.Equals("zero-digit")) { * symbols.setZeroDigit((value)); * } else if (property.Equals("digit")) { * symbols.setDigit((value)); * } else if (property.Equals("pattern-separator")) { * symbols.setPatternSeparator((value)); * } else { * driver.println("**** Unknown decimal format attribute " + property); * } * } catch (XPathException e) { * driver.println("**** " + e.getMessage()); * } * } * environment.paramDecimalDeclarations.append(";"); * try { * symbols.checkConsistency(formatQName); * } catch (XPathException err) { * driver.println("**** " + err.getMessage()); * } * * } * }*/ private static void CreateUnparsedTextResolver(TestDriver driver, XPathCompiler xpc, XdmItem env, Environment environment) { Dictionary <Uri, Object> resources = new Dictionary <Uri, Object>(); Dictionary <Uri, String> encodings = new Dictionary <Uri, String>(); XmlUrlResolver res = new XmlUrlResolver(); foreach (XdmItem resource in xpc.Evaluate("resource", env)) { String uri = ((XdmNode)resource).GetAttributeValue(new QName("uri")); String href = ((XdmNode)resource).GetAttributeValue(new QName("file")); String encoding = ((XdmNode)resource).GetAttributeValue(new QName("encoding")); if (href != null) { Object obj = null; if (href.StartsWith("http")) { try { obj = new Uri(href); } catch (Exception e) { throw e; } } else { obj = new java.io.File(res.ResolveUri(((XdmNode)env).BaseUri, href).AbsolutePath); } try { resources.Add(new Uri(uri), obj); encodings.Add(new Uri(uri), encoding); Uri abs = res.ResolveUri(((XdmNode)resource).BaseUri, uri); resources.Add(abs, obj); encodings.Add(abs, encoding); } catch (Exception e) { driver.println("** Invalid URI in environment: " + e.Message); } } } if (resources.Count != 0) { environment.unparsedTextResolver = new UnparsedTextURIResolver(encodings, resources); } }
public FileMatcher(File file) { field_22209_a = file; Matcher matcher = ChunkFilePattern.field_22119_a.matcher(file.getName()); if (matcher.matches()) { field_22208_b = Integer.parseInt(matcher.group(1), 36); field_22210_c = Integer.parseInt(matcher.group(2), 36); } else { field_22208_b = 0; field_22210_c = 0; } }
//Timer event private void dispatcherTimer_Tick(object sender, EventArgs e) { time--; CountDownBlk.Text = string.Format("0{0}:{1}", time / 60, time % 60); if (time < 5) { if (time % 2 == 0) { CountDownBlk.Foreground = Brushes.Red; } else { CountDownBlk.Foreground = Brushes.DarkRed; } } if (time == 0) { dispatcherTimer.Stop(); wavSource.StopRecording(); polyLine.Points.Clear(); ReadAudioForm3.backButton.Enabled = true; ReadAudioForm3.submitButton.Enabled = true; ReadAudioForm3.ActiveForm.Size = new System.Drawing.Size(322, 400); //The recorded voice of the student String recordWAV_file = @"C:\Pres_Proto\V2\MetroFrameworkDLLExample\RecordWAV\" + lvlStr + ".wav"; //The reference sample of the teacher String refWAV_file = "Class" + LoginForm.classSec + "_kidAudio/" + lvlStr.ToLower() + ".wav"; java.io.File f1 = new java.io.File(recordWAV_file); java.io.File f2 = new java.io.File(refWAV_file); //compare if (!f1.exists() || !f2.exists()) { MessageBox.Show("WARNING: One of the files might be missing!"); } else { CallCompareAudio(recordWAV_file, refWAV_file); } //MessageBox.Show("DONE"); time = 10; } }
public static bool ToFile(string filePath, Table table, TableContainType tableContainType) { FileInfo _csvfilesave = new FileInfo(filePath); if (!Directory.Exists(_csvfilesave.DirectoryName)) { Directory.CreateDirectory(_csvfilesave.DirectoryName); } java.io.File outputFile = new java.io.File(filePath); BufferedWriter bufferedWriter = null; try { var fileWriter = new OutputStreamWriter(new FileOutputStream(outputFile.getAbsoluteFile()), "UTF-8"); bufferedWriter = new BufferedWriter(fileWriter); outputFile.createNewFile(); technology.tabula.writers.Writer writer = null; switch (tableContainType) { case TableContainType.CSV: writer = new CSVWriter(); break; case TableContainType.Json: writer = new JSONWriter(); break; case TableContainType.TSV: writer = new TSVWriter(); break; default: writer = new JSONWriter(); break; } writer.write(bufferedWriter, table); } catch { return(false); } return(true); }
public void trainMachineForEmotionUsingWeka(string wekaFile, string modelName, int hiddelLayers = 7, double learningRate = 0.03, double momentum = 0.4, int decimalPlaces = 2, int trainingTime = 1000) { //"C:\\Users\\Gulraiz\\Desktop\\Genereted2.arff" "MLP" try { weka.core.Instances insts = new weka.core.Instances(new java.io.FileReader(wekaFile)); insts.setClassIndex(insts.numAttributes() - 1); weka.classifiers.functions.MultilayerPerceptron cl; cl = new weka.classifiers.functions.MultilayerPerceptron(); cl.setHiddenLayers(hiddelLayers.ToString()); cl.setLearningRate(learningRate); cl.setMomentum(momentum); cl.setNumDecimalPlaces(decimalPlaces); cl.setTrainingTime(trainingTime); System.Console.WriteLine("Performing " + percentSplit + "% split evaluation."); //randomize the order of the instances in the dataset. weka.filters.Filter myRandom = new weka.filters.unsupervised.instance.Randomize(); myRandom.setInputFormat(insts); insts = weka.filters.Filter.useFilter(insts, myRandom); int trainSize = insts.numInstances() * percentSplit / 100; int testSize = insts.numInstances() - trainSize; weka.core.Instances train = new weka.core.Instances(insts, 0, trainSize); java.io.File path = new java.io.File("/models/"); cl.buildClassifier(train); saveModel(cl, modelName, path); #region test whole set //int numCorrect = 0; //for (int i = trainSize; i < insts.numInstances(); i++) //{ // weka.core.Instance currentInst = insts.instance(i); // double predictedClass = cl.classifyInstance(currentInst); // if (predictedClass == insts.instance(i).classValue()) // numCorrect++; //} //System.Console.WriteLine(numCorrect + " out of " + testSize + " correct (" + // (double)((double)numCorrect / (double)testSize * 100.0) + "%)"); #endregion } catch (java.lang.Exception ex) { ex.printStackTrace(); } }
public TextExtractionResult Extract(string filePath) { try { var file = new File(filePath); return Extract(metadata => { var result = TikaInputStream.get(file, metadata); metadata.add("FilePath", filePath); return result; }); } catch (Exception ex) { throw new TextExtractionException("Extraction of text from the file '{0}' failed.".ToFormat(filePath), ex); } }
public void TestTikaAutodetect() { Tika tika = new Tika(); File xpsFile = new File("samples\\test1.xps"); if (!xpsFile.isFile()) throw new Exception(xpsFile.getName() + " does not exists."); using (InputStream inputStream = new FileInputStream(xpsFile)) { Metadata metadata = new Metadata(); string mimeType = tika.detect(inputStream, metadata); Assert.AreEqual("application/x-tika-ooxml", mimeType); inputStream.close(); } }
public static bool delete0(object _this, java.io.File f) { throw new NotImplementedException(); //FileSystemInfo fileInfo = null; //try //{ // string path = GetPathFromFile(f); // if (Directory.Exists(path)) // { // fileInfo = new DirectoryInfo(path); // } // else if (File.Exists(path)) // { // fileInfo = new FileInfo(path); // } // else // { // return false; // } // // We need to be able to delete read-only files/dirs too, so we clear // // the read-only attribute, if set. // if ((fileInfo.Attributes & FileAttributes.ReadOnly) != 0) // { // fileInfo.Attributes &= ~FileAttributes.ReadOnly; // } // fileInfo.Delete(); // return true; //} //catch (SecurityException) //{ //} //catch (ArgumentException) //{ //} //catch (UnauthorizedAccessException) //{ //} //catch (IOException) //{ //} //catch (NotSupportedException) //{ //} //return false; }
public static bool delete0(object _this, java.io.File f) { FileSystemInfo fileInfo = null; try { string path = GetPathFromFile(f); if (Directory.Exists(path)) { fileInfo = new DirectoryInfo(path); } else if (File.Exists(path)) { fileInfo = new FileInfo(path); } else { return(false); } // We need to be able to delete read-only files/dirs too, so we clear // the read-only attribute, if set. if ((fileInfo.Attributes & FileAttributes.ReadOnly) != 0) { fileInfo.Attributes &= ~FileAttributes.ReadOnly; } fileInfo.Delete(); return(true); } catch (SecurityException) { } catch (ArgumentException) { } catch (UnauthorizedAccessException) { } catch (IOException) { } catch (NotSupportedException) { } return(false); }
private void getDir(string dirPath) { myPath.setText("Location: " + dirPath); item = new ArrayList(); path = new ArrayList(); File f = new File(dirPath); File[] files = f.listFiles(); //if (!(root.StringEquals(dirPath))) //if (root != dirPath) { item.add(root); path.add(root); item.add("../"); path.add(f.getParent()); } if (files != null) for (int i = 0; i < files.Length; i++) { File file = files[i]; if (!file.isHidden() && file.canRead()) { path.add(file.getPath()); if (file.isDirectory()) { item.add(file.getName() + "/"); } else { item.add(file.getName()); } } } var fileList = new ArrayAdapter(this, R.layout.row, item); //new ArrayAdapter<String>(this, R.layout.row, item); setListAdapter(fileList); }
public void trainMachineForHybridUsingWeka(string wekaFile, string modelName) { weka.core.Instances insts = new weka.core.Instances(new java.io.FileReader(wekaFile)); insts.setClassIndex(insts.numAttributes() - 1); weka.classifiers.Classifier bagging = new weka.classifiers.meta.Bagging(); System.Console.WriteLine("Performing " + percentSplit + "% split evaluation."); //randomize the order of the instances in the dataset. weka.filters.Filter myRandom = new weka.filters.unsupervised.instance.Randomize(); myRandom.setInputFormat(insts); insts = weka.filters.Filter.useFilter(insts, myRandom); int trainSize = insts.numInstances() * percentSplit / 100; int testSize = insts.numInstances() - trainSize; weka.core.Instances train = new weka.core.Instances(insts, 0, trainSize); java.io.File path = new java.io.File("/models/"); bagging.buildClassifier(train); saveModel(bagging, modelName, path); }
public PropertyManager(File file) { serverProperties = new Properties(); serverPropertiesFile = file; if (file.exists()) { try { serverProperties.load(new FileInputStream(file)); } catch (Exception exception) { logger.log(Level.WARNING, (new StringBuilder()).append("Failed to load ").append(file).toString(), exception); generateNewProperties(); } } else { logger.log(Level.WARNING, (new StringBuilder()).append(file).append(" does not exist").toString()); generateNewProperties(); } }
public static File findFileOnClassPath(string name) { StringTokenizer stringTokenizer = new StringTokenizer(System.getProperty("java.class.path"), System.getProperty("path.separator")); while (stringTokenizer.hasMoreTokens()) { File file1 = new File(stringTokenizer.nextToken()); File absoluteFile = file1.getAbsoluteFile(); if (absoluteFile.isFile()) { File.__\u003Cclinit\u003E(); File file2 = new File(absoluteFile.getParent(), name); if (file2.exists()) return file2; } else { File file2 = new File(file1, name); if (file2.exists()) return file2; } } return (File) null; }
public void func_22091_b() { try { var file = new File(field_22099_b, "session.lock"); var datainputstream = new DataInputStream(new FileInputStream(file)); try { if (datainputstream.readLong() != field_22100_d) { throw new MinecraftException("The save is being accessed from another location, aborting"); } } finally { datainputstream.close(); } } catch (IOException) { throw new MinecraftException("Failed to check session lock, aborting"); } }
public ServerConfigurationManager(MinecraftServer minecraftserver) { playerEntities = new ArrayList(); bannedPlayers = new HashSet(); bannedIPs = new HashSet(); ops = new HashSet(); whiteListedIPs = new HashSet(); mcServer = minecraftserver; bannedPlayersFile = minecraftserver.getFile("banned-players.txt"); ipBanFile = minecraftserver.getFile("banned-ips.txt"); opFile = minecraftserver.getFile("ops.txt"); whitelistPlayersFile = minecraftserver.getFile("white-list.txt"); playerManagerObj = new PlayerManager(minecraftserver); maxPlayers = minecraftserver.propertyManagerObj.getIntProperty("max-players", 20); whiteListEnforced = minecraftserver.propertyManagerObj.getBooleanProperty("white-list", false); readBannedPlayers(); loadBannedList(); loadOps(); loadWhiteList(); writeBannedPlayers(); saveBannedList(); saveOps(); saveWhiteList(); }
public static MaxCore storedLocally(File storedResults) { return new MaxCore(storedResults); }
/// <summary> /// Executes the specified command and arguments in a separate process with the specified environment and working directory. /// </summary> public Process exec(string[] cmdarray, string[] envp, File dir) { return default(Process); }
/// <summary> /// Obtains an audio input stream from the provided <code>File</code>. /// </summary> static public AudioInputStream getAudioInputStream(File @file) { return default(AudioInputStream); }
/// <summary> /// Obtains the audio file format of the specified <code>File</code>. /// </summary> static public AudioFileFormat getAudioFileFormat(File @file) { return default(AudioFileFormat); }
public virtual Component getTableCellEditorComponent([In] JTable obj0, [In] object obj1, [In] bool obj2, [In] int obj3, [In] int obj4) { JFileChooser jfileChooser = this.this\u00240.chooser; File.__\u003Cclinit\u003E(); File file = new File((string) this.this\u00240.getValue()); jfileChooser.setSelectedFile(file); switch (this.this\u00240.chooser.showDialog(this.c, "Select")) { case 0: this.this\u00240.setValue((object) this.this\u00240.chooser.getSelectedFile()); break; } this.label.setText(String.instancehelper_toString((string) this.this\u00240.getValue())); return (Component) this.label; }
/// <summary> /// Executes the specified string command in a separate process with the specified environment and working directory. /// </summary> public Process exec(string command, string[] envp, File dir) { return default(Process); }
private void saveBytecode(String className, byte[] bytecode) { var generatedPath = PathHelper.combine(System.getProperty("user.dir"), "Tests/resources/TypeBuilderTest/stab"); var generatedDir = new File(generatedPath); if (!generatedDir.exists()) { generatedDir.mkdir(); } var stream = new FileOutputStream(PathHelper.combine(generatedPath, className + ".class")); stream.write(bytecode); stream.close(); }