//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static void copyfile(String source, String destination) throws org.maltparser.core.exception.MaltChainedException public static void copyfile(string source, string destination) { try { sbyte[] readBuffer = new sbyte[BUFFER]; BufferedInputStream bis = new BufferedInputStream(new FileStream(source, FileMode.Open, FileAccess.Read)); BufferedOutputStream bos = new BufferedOutputStream(new FileStream(destination, FileMode.Create, FileAccess.Write), BUFFER); int n = 0; while ((n = bis.read(readBuffer, 0, BUFFER)) != -1) { bos.write(readBuffer, 0, n); } bos.flush(); bos.close(); bis.close(); } catch (FileNotFoundException e) { throw new MaltChainedException("The destination file '" + destination + "' cannot be created when coping the file. ", e); } catch (IOException e) { throw new MaltChainedException("The source file '" + source + "' cannot be copied to destination '" + destination + "'. ", e); } }
private static sbyte[] readFile(Jfile file) { InputStream @in = new BufferedInputStream(new FileInputStream(file)); ByteArrayOutputStream bytes = new ByteArrayOutputStream(new FileStream(file.Name, FileMode.Open)); try { sbyte[] buffer = new sbyte[1024]; int length; while ((length = @in.read(buffer, 0, buffer.Length)) > 0) { bytes.write(buffer, 0, length); } } finally { try { @in.close(); } catch (IOException) { // sorry that this can fail! } } return(bytes.toSbyteArray()); }
public void UnZip(string zipFileLocation, string destinationRootFolder, string zipRootToRemove) { try { var zipFile = new ZipFile(zipFileLocation); var zipFileEntries = zipFile.entries(); while (zipFileEntries.hasMoreElements()) { var zipEntry = (ZipEntry)zipFileEntries.nextElement(); var name = zipEntry.getName().Replace(zipRootToRemove, "").Replace("/", "\\").TrimStart('/').TrimStart('\\'); var p = this.fileSystem.Path.Combine(destinationRootFolder, name); if (zipEntry.isDirectory()) { if (!this.fileSystem.Directory.Exists(p)) { this.fileSystem.Directory.CreateDirectory(p); } ; } else { using (var bis = new BufferedInputStream(zipFile.getInputStream(zipEntry))) { var buffer = new byte[2048]; var count = buffer.GetLength(0); using (var fos = new FileOutputStream(p)) { using (var bos = new BufferedOutputStream(fos, count)) { int size; while ((size = bis.read(buffer, 0, count)) != -1) { bos.write(buffer, 0, size); } bos.flush(); bos.close(); } } bis.close(); } } } zipFile.close(); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { var t = e.ToString(); } }
public virtual void AES256IGEDecrypt(string sourceFile, string destFile, byte[] iv, byte[] key) { int num1; File file = new File(sourceFile); File file2 = new File(destFile); AESFastEngine engine = new AESFastEngine(); engine.init(false, new KeyParameter(key)); byte[] buffer = CryptoUtils.substring(iv, 0x10, 0x10); byte[] buffer2 = CryptoUtils.substring(iv, 0, 0x10); BufferedInputStream.__ <clinit>(); BufferedInputStream stream = new BufferedInputStream(new FileInputStream(file)); BufferedOutputStream stream2 = new BufferedOutputStream(new FileOutputStream(file2)); byte[] buffer3 = new byte[0x10]; Label_0060: num1 = stream.read(buffer3); if (num1 <= 0) { stream2.flush(); stream2.close(); stream.close(); } else { byte[] @in = new byte[0x10]; int index = 0; while (true) { if (index >= 0x10) { break; } @in[index] = (byte)((sbyte)(buffer3[index] ^ buffer[index])); index++; } engine.processBlock(@in, 0, @in, 0); index = 0; while (true) { if (index >= 0x10) { break; } @in[index] = (byte)((sbyte)(@in[index] ^ buffer2[index])); index++; } buffer2 = buffer3; buffer = @in; buffer3 = new byte[0x10]; stream2.write(@in); goto Label_0060; } }
public static ImmutableFst loadModel(InputStream inputStream) { BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream); ObjectInputStream objectInputStream = new ObjectInputStream(bufferedInputStream); ImmutableFst result = ImmutableFst.readImmutableFst(objectInputStream); objectInputStream.close(); bufferedInputStream.close(); inputStream.close(); return(result); }
public static byte[] getBytesFromFileJava(string filePath) { FileInputStream fis = new FileInputStream(new java.io.File(filePath)); BufferedInputStream bis = new BufferedInputStream(fis); int numByte = bis.available(); byte[] buff = new byte[numByte]; bis.read(buff, 0, numByte); bis.close(); fis.close(); return(buff); }
public static Fst loadModel(string filename) { long timeInMillis = Calendar.getInstance().getTimeInMillis(); FileInputStream fileInputStream = new FileInputStream(filename); BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream); ObjectInputStream objectInputStream = new ObjectInputStream(bufferedInputStream); Fst result = Fst.readFst(objectInputStream); objectInputStream.close(); bufferedInputStream.close(); fileInputStream.close(); java.lang.System.err.println(new StringBuilder().append("Load Time: ").append((double)(Calendar.getInstance().getTimeInMillis() - timeInMillis) / 1000.0).toString()); return(result); }
public virtual T load(Jfile modelFile) { long beginModelLoadingTime = DateTimeHelperClass.CurrentUnixTimeMillis(); CmdLineUtil.checkInputFile(modelName + " model", modelFile); Console.Error.Write("Loading " + modelName + " model ... "); InputStream modelIn = new BufferedInputStream(CmdLineUtil.openInFile(modelFile), CmdLineUtil.IO_BUFFER_SIZE); T model; try { model = loadModel(modelIn); } catch (InvalidFormatException e) { Console.Error.WriteLine("failed"); throw new TerminateToolException(-1, "Model has invalid format", e); } catch (IOException e) { Console.Error.WriteLine("failed"); throw new TerminateToolException(-1, "IO error while loading model file '" + modelFile + "'", e); } finally { // will not be null because openInFile would // terminate in this case try { modelIn.close(); } catch (IOException) { // sorry that this can fail } } long modelLoadingDuration = DateTimeHelperClass.CurrentUnixTimeMillis() - beginModelLoadingTime; System.err.printf("done (%.3fs)\n", modelLoadingDuration / 1000d); return(model); }
public static AudioData readAudioFile(string filename) { AudioData result; try { BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(filename)); AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(bufferedInputStream); AudioData audioData = new AudioData(audioInputStream); bufferedInputStream.close(); result = audioData; } catch (UnsupportedAudioFileException) { goto IL_31; } return(result); IL_31: return(null); }
public new static ImmutableFst loadModel(string filename) { ImmutableFst result; try { try { try { FileInputStream fileInputStream = new FileInputStream(filename); BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream); ObjectInputStream objectInputStream = new ObjectInputStream(bufferedInputStream); result = ImmutableFst.readImmutableFst(objectInputStream); objectInputStream.close(); bufferedInputStream.close(); fileInputStream.close(); } catch (FileNotFoundException ex) { Throwable.instancehelper_printStackTrace(ex); return(null); } } catch (IOException ex3) { Throwable.instancehelper_printStackTrace(ex3); return(null); } } catch (ClassNotFoundException ex5) { Throwable.instancehelper_printStackTrace(ex5); return(null); } return(result); }