aspose file tools*
The moose likes C / C++ and the fly likes can anyone convert c# code to java code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » C / C++
Bookmark "can anyone convert c# code to java code" Watch "can anyone convert c# code to java code" New topic
Author

can anyone convert c# code to java code

sam sawant
Greenhorn

Joined: Mar 26, 2009
Posts: 12


this is a code in c# i want to convert it to java , specially the part where tag from the reader can be read & then printed to PC


[ EJFH: Added code tags. ]
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9524
    
    2

Look for some online tools that do such jobs or write one in java for yourself!


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5843
    
    7

Sam, welcome to Java Ranch

I once translated a large Java app to C# and the steps I did was to rename the source files, run then through the compiler, and fix the problems that the compiler found. Some things, such as changing System.out.println to Console.WriteLine were easy to accomplish globally by a decent text editor. In one case (generation of an image in memory) I had to completely rewrite the code.

However, Looking at this code, I don't see anything that would be hard to translate to Java by hand. Or were you hoping for someone to do this for you?


JBoss In Action
sam sawant
Greenhorn

Joined: Mar 26, 2009
Posts: 12
the prob is when i converted this code to java is not working with the hardware,
especiallt the read tag function,
so do help me to convert read tag function in java


while reading from a keyboard we use readline() method, so what will be the inbuilt method to read from a hardware.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5843
    
    7

Please post the Java code you have so far. Does your code compile? If you run it, is there and exception? Is so, post the full exception stack trace. If there is no exception, please elaborate on what you mean by "not working with the hardware"

so what will be the inbuilt method to read from a hardware


What hardware? In .NET and Java, input is handled via streams. This is true for keyboard, file, socket, etc. Based on your code, looks you are attempting to read from a socket. Maybe this will help: http://java.sun.com/docs/books/tutorial/networking/sockets/readingWriting.html
Anand Hariharan
Rancher

Joined: Aug 22, 2006
Posts: 257

Peter Johnson wrote:
I once translated a large Java app to C# and the steps I did was to rename the source files, run then through the compiler, and fix the problems that the compiler found. Some things, such as changing System.out.println to Console.WriteLine were easy to accomplish globally by a decent text editor. In one case (generation of an image in memory) I had to completely rewrite the code.

While I've never undertaken anything quite like this in a long time (I had to rewrite several projects written in VB 6 to C++ some years ago), it is nice to learn that C# and Java are so similar that translating takes no more than changing the file name extension, and make the tweaks suggested by the compiler. Cool.


"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- Antoine de Saint-Exupery
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can anyone convert c# code to java code