JavApi
Stable release | 0.8.0.1 / 2012-07-09 |
---|---|
Type | API |
License | Apache License |
Website | JavApi@Codeplex |
JavApi[1] provides a collection of .NET classes in the form of the Java API. It thus allows you to use an identical API to develop for both platforms. It is a rewrite of the Java API from Oracle Corporation based on some Open Source implementations with C#.
Functionality
JavApi is used to implement .NET/CLR application by the same API calls like Java and is documented with Java API documentation.
Examples
Java | CSharp JavApi | CSharp |
package javapi.sample.util.zip; public class SampleGZIPOutputStream2File { public static void main(String[] args) throws Exception { String outFilename = "c:/temp/outfile.gzip"; java.util.zip.GZIPOutputStream outJ = new java.util.zip.GZIPOutputStream( new java.io.FileOutputStream(outFilename)); String inFilename = "c:/README.txt"; java.io.FileInputStream inJ = new java.io.FileInputStream(inFilename); byte[] buf = new byte[1024]; int len; while ((len = inJ.read(buf)) > 0) { outJ.write(buf, 0, len); } inJ.close(); outJ.finish(); outJ.close(); } } ¤ |
using System; using java = biz.ritter.javapi; namespace javapi.sample.util.zip { class SampleGZIPOutputStream2File { static void Main () { String outFilename = "c:/temp/outfile.gzip"; java.util.zip.GZIPOutputStream outJ = new java.util.zip.GZIPOutputStream( new java.io.FileOutputStream(outFilename)); String inFilename = "c:/README.txt"; java.io.FileInputStream inJ = new java.io.FileInputStream(inFilename); byte[] buf = new byte[1024]; int len; while ((len = inJ.read(buf)) > 0) { outJ.write(buf, 0, len); } inJ.close(); outJ.finish(); outJ.close(); } } }¤ |
using System; namespace javapi.sample.util.zip { class SampleGZIPOutputStream2FileCSharp { static void Main () { String outFilename = "c:/temp/outfile.gzip"; System.IO.Compression.GZipStream outJ = new System.IO.Compression.GZipStream ( new System.IO.FileStream (outFilename, System.IO.FileMode.Create), System.IO.Compression.CompressionMode.Compress); String inFilename = "c:/README.txt"; System.IO.FileStream inJ = new System.IO.FileStream (inFilename, System.IO.FileMode.Open); byte [] buf = new byte [1024]; int len; while ((len = inJ.Read(buf,0,buf.Length)) >0) { outJ.Write (buf,0,len); } inJ.Close(); outJ.Flush (); outJ.Close(); } } }¤ |