Looking for the Code Converter which converts C# to Java
Disclaimer: No tool is perfect.
However, if you still want to try then there are these converters available:
- CS2J
- JCLA : Convert Java-language code to C#
- Grasshopper
- CSharpJavaMerger
- Tangible Software C# to Java Converter
Not a converter but a bridge between .NET and the JVM:
- JNI4NetBridge
How to rewrite or convert C# code in Java code?
I'd suggest building for Mono. You'll run into some gray area, but overall it's great. However, if you want to build for Java, you might check out Grasshopper. It's a commercial product, but it claims to be able to translate CIL (the output of the C# compiler) to Java bytecodes.
How can I convert my short C# code to java
This should produce the same result:
import java.security.*;
import java.io.*;
import java.math.*;
private static String GetMd5Sum(String productIdentifier) throws UnsupportedEncodingException, NoSuchAlgorithmException {
byte[] bytesOfMessage = productIdentifier.getBytes("UTF-16LE");
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] digest = md.digest(bytesOfMessage);
BigInteger i = new BigInteger(1, digest);
return String.format("%1$032X", i);
}
This answer is based on this answer but changed to use UTF-16LE to match C#'s Encoding.Unicode
.
Convert an c# Winforms Application to Java
There are some tools for converting codes but they are only working correctly with little code blocks. An entire project requires a different complier, framework, libraries etc.. So yes, you must redo the entire code only with little convertings with that tools. But I don't recommend that. They may split apart your code integrity.
Port C# Code to Java
I assume that the above struct is actually used to overlay (effectively) an array of bits as a byte
array or an int
array.
You can't do that in Java. Your choices are:
- Model it as a
byte
array, and take the performance hit when you are doing indexed copying. - Model it as an
int
array, and use bit shifting and masking to do the byte-wise operations. - Use native code; i.e. code the encryption / decryption in C or C++ and use JNI or JNA or similar to call that code from Java.
You could also look at the IntBuffer
or ByteBuffer
classes. These are (IMO) unlikely improve performance for your encryption / decryption operations taken in isolation, but when you combine them with NIO I/O (as an alternative to old-school I/O + copying to / from arrays) you may get better performance.
But it is also worth pointing out that this all has the smell of premature optimization. I'd recommend writing the Java code the simplest way first, and worry about performance later .... if measurement tells you that it is a real concern.
Related Topics
What Does the Colon (:) Operator Do
What Is the Best/Simplest Way to Read in an Xml File in Java Application
Transform Java Future into a Completablefuture
Injecting Beans into a Class Outside the Spring Managed Context
Java - Delete Line from Text File by Overwriting While Reading It
Cast Object to Generic Type for Returning
Is Polymorphism Possible Without Inheritance
Do Java Primitives Go on the Stack or the Heap
Jvm Option -Xss - What Does It Do Exactly
How to Use Conditional Breakpoint in Eclipse
Difference Between "Char" and "String" in Java
Meaning of New Class(...){{...}} Initialization Idiom
Build Project into a Jar Automatically in Eclipse
Java.Sql.Sqlexception: Incorrect String Value: '\Xf0\X9F\X91\Xbd\Xf0\X9F...'