Interesting comparison: Java and C #.

Source: Internet
Author: User

Before writing, I declare that I am very dish and lazy.

Let's take a look at the cause.

I want to pass a file to C # Through Java through the network. Because I am very lazy, I chose web service and only wanted to pass the simple type, so I remembered base64, so I decided to use base64 encoding to provide web services through Java, called by C.

You must first compile the base64 code. If you do not compile it in Java, You must select C # encoding. You must save the code as a text file and use Java to read and compare it. Then, you can read the text file.

C #:

Streamreader reader = file. opentext ("C: // data.txt ");

This. Buffer = reader. readtoend ();

Java:

Bufferedreader reader = new bufferedreader (New filereader ("C: // data.txt "));

Return reader. Readline ();

I am so depressed ,. net, while Java can only read one row. net, the idea is very clear, to read files, must file, what to do? File. open ..., ah, I found opentext In the IDE prompt. This is what I want. Bless me as a string file name... bingo... I guessed it. I was excited to add the file name, and the file exists. opentext ("C: // data.txt"), which is written in this way at the beginning. This. buffer = file. opentext ("C: // data.txt "). readtoend (); because I clicked ide again and gave me a prompt, I found readtoend (), and later I wanted reader. close (), so the separation is also a matter of course, with vs programming, just like talking to it.

In Java, It is very depressing. Reader cannot read all but Readline. I am very confused. So I opened the help for JB, and searched for readall with Java API. What is the result? image. nothing, let alone how to use Java to encode base64.

I don't want to comment on who is doing well. Maybe I am too lazy, and I like C # a bit.

In addition, when using C # to read the text, it is easy to read, and the reader of Java. readline (), actually let my JB stop responding. Haha, maybe I really don't blame java. This line is too long, so long as 2 M: O.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.