Ejemplo n.º 1
0
        // http://www.java-tips.org/java-se-tips/java.io/reading-a-file-into-a-byte-array.html
        static sbyte[] getBytesFromFile(global::java.io.File file)
        {
            try
            {
                var istream = new global::java.io.FileInputStream(file);

                // Get the size of the file
                long length = file.length();



                // Create the byte array to hold the data
                var bytes = new sbyte[(int)length];

                // Read in the bytes
                int offset  = 0;
                int numRead = istream.read(bytes, offset, bytes.Length - offset);

                if (numRead >= 0)
                {
                    while (offset < bytes.Length)
                    {
                        offset += numRead;
                        numRead = istream.read(bytes, offset, bytes.Length - offset);

                        if (numRead < 0)
                        {
                            break;
                        }
                    }
                }



                // Close the input stream and return bytes
                istream.close();
                return(bytes);
            }
            catch //(Exception e)
            {
                //((java.lang.Throwable)(object)e).printStackTrace();

                // exception mapping must be refactored
                //throw new csharp.RuntimeException("File: " + file.ToString() + "Message: " + e.Message);

                throw;
            }
        }
Ejemplo n.º 2
0
public virtual global::System.Object parse(global::java.io.File n1){
//XMLVM_BEGIN_WRAPPER[javax.xml.parsers.DocumentBuilder: org.w3c.dom.Document parse(java.io.File)]
    global::System.Object _r0_o = null;
    global::System.Object _r1_o = null;
    global::System.Object _r2_o = null;
    global::System.Object _r3_o = null;
    _r2_o = this;
    _r3_o = n1;
    if (_r3_o != null) goto label10;
    _r0_o = new global::java.lang.IllegalArgumentException();
    // Value=file is null
    _r1_o = new global::java.lang.String();
    ((global::java.lang.String)_r1_o).@this(new global::org.xmlvm._nArrayAdapter<char>(new char[] {unchecked((char) unchecked((uint)102)), unchecked((char) unchecked((uint) 105)), unchecked((char) unchecked((uint) 108)), unchecked((char) unchecked((uint) 101)), unchecked((char) unchecked((uint) 32)), unchecked((char) unchecked((uint) 105)), unchecked((char) unchecked((uint) 115)), unchecked((char) unchecked((uint) 32)), unchecked((char) unchecked((uint) 110)), unchecked((char) unchecked((uint) 117)), unchecked((char) unchecked((uint) 108)), unchecked((char) unchecked((uint) 108))}));
    ((global::java.lang.IllegalArgumentException) _r0_o).@this((global::java.lang.String) _r1_o);
    throw new global::org.xmlvm._nExceptionAdapter((global::java.lang.IllegalArgumentException) _r0_o);
    label10:;
    _r0_o = new global::org.xml.sax.InputSource();
    _r1_o = new global::java.io.FileInputStream();
    ((global::java.io.FileInputStream) _r1_o).@this((global::java.io.File) _r3_o);
    ((global::org.xml.sax.InputSource) _r0_o).@this((global::java.io.InputStream) _r1_o);
    _r1_o = ((global::java.io.File) _r3_o).toURL();
    _r1_o = ((global::java.net.URL) _r1_o).toString();
    ((global::org.xml.sax.InputSource) _r0_o).setSystemId((global::java.lang.String) _r1_o);
    _r0_o = ((global::javax.xml.parsers.DocumentBuilder) _r2_o).parse((global::org.xml.sax.InputSource) _r0_o);
    return (global::org.w3c.dom.Document) _r0_o;
//XMLVM_END_WRAPPER[javax.xml.parsers.DocumentBuilder: org.w3c.dom.Document parse(java.io.File)]
}
Ejemplo n.º 3
0
        // http://www.java-tips.org/java-se-tips/java.io/reading-a-file-into-a-byte-array.html
        static sbyte[] getBytesFromFile(global::java.io.File file)
        {
            try
            {

                var istream = new global::java.io.FileInputStream(file);

                // Get the size of the file
                long length = file.length();



                // Create the byte array to hold the data
                var bytes = new sbyte[(int)length];

                // Read in the bytes
                int offset = 0;
                int numRead = istream.read(bytes, offset, bytes.Length - offset);

                if (numRead >= 0)
                    while (offset < bytes.Length)
                    {
                        offset += numRead;
                        numRead = istream.read(bytes, offset, bytes.Length - offset);

                        if (numRead < 0)
                            break;
                    }



                // Close the input stream and return bytes
                istream.close();
                return bytes;
            }
            catch //(Exception e)
            {
                //((java.lang.Throwable)(object)e).printStackTrace();

                // exception mapping must be refactored
                //throw new csharp.RuntimeException("File: " + file.ToString() + "Message: " + e.Message);

                throw;
            }
        }