java.io.RandomAccessFile.writeByte C# (CSharp) Method

writeByte() public method

public writeByte ( int arg0 ) : void
arg0 int
return void
        public virtual void writeByte(int arg0)
        {
            global::MonoJavaBridge.JavaBridge.CallVoidMethod(this, global::java.io.RandomAccessFile.staticClass, "writeByte", "(I)V", ref global::java.io.RandomAccessFile._m25, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0));
        }

Usage Example

Exemplo n.º 1
0
        //public static void WriteHexDumpFromFile(string filename)
        //{
        //    try
        //    {
        //        File file = new File(filename);

        //        RandomAccessFile stream = new RandomAccessFile(file, "r");

        //        sbyte[] bytes = new sbyte[stream.length()];

        //        stream.read(bytes);

        //        stream.close();

        //        System.Console.WriteLine("dump of [" + file + "]");
        //        Console.WriteHexDump(bytes);
        //    }
        //    catch (Exception exc)
        //    {

        //        Console.WriteThrowable(exc);
        //    }


        //}

        /// <summary>
        /// writes bytes to file
        /// </summary>
        /// <param name="cdata"></param>
        /// <param name="p"></param>
        public static void WriteBytes(sbyte[] cdata, string filename, bool utf8)
        {
            try
            {
                File f = new File(filename);

                if (f.exists())
                    f.delete();

                RandomAccessFile stream = new RandomAccessFile(filename, "rw");

                if (utf8)
                {
                    stream.writeByte(0xEF);
                    stream.writeByte(0xBB);
                    stream.writeByte(0xBF);
                }

                stream.write(cdata);

                stream.close();
            }
            catch
            {

            }
        }