Very interesting comparison between Java and C #.

Source: Internet
Author: User
Tags base64 readline

Before you write, declare that I am very vegetable, and very lazy.

For a reason, look at the reasons first.

I want to pass a file through the network from Java to C #, because I am lazy, choose the Web service, and just want to pass the simple type, so I think of Base64, so I decided to use the Base64 code after the Java to provide Web service, called by C #.

Must first into the Base64 code bar, with Java will not be compiled, choose the C # code, have to save into a text file, read in Java, compared to, from reading text files.

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 ();

See here, I really depressed,. NET can read all, and Java can read only one line, in. Net thinking very clear, to read the file, definitely to files, do what. File.Open ..., ah, from the IDE's tip I found OpenText, this is what I want, bless me is the filename of a string ... bingo ... I guessed the excitement to add the filename into the File.OpenText ("C://data.txt"), at the beginning I wrote this, This.buffer = File.OpenText ("C://data.txt"). ReadToEnd (); Because I ordered it again. The IDE gave me a hint, and I found ReadToEnd (), and later because I wanted to reader. Close (), so separate, which is also a logical thing to do, with VS programming, as in dialogue with it.

Java is very depressing, reader is not readall only ReadLine, I was confused, so open Help JB Help, with the Java API, find ReadAll, The result is what image. What, let alone how to use Java code base64.

I do not want to comment who good who bad, maybe really I am too lazy, I kind of like on C #.

In addition, in C # reading text, it is easy to read, and the Java Reader.readline (), incredibly let my jb stop responding, oh, maybe really don't blame Java, my line is too long, 2M so long: 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.