我总算知道为什么java在web方面干不过php了。
php就是简单得好,在这个追求开发效率而不是程序运行效率的年代,php就一个函数 file_get_contents — Reads entire file into a string
再看看msdn里面的c#
using System;
using System.IO;
public class TextFromFile
{
private const string FILE_NAME = "MyFile.txt";
public static void Main(String[] args)
{
if (!File.Exists(FILE_NAME))
{
Console.WriteLine("{0} does not exist.", FILE_NAME);
return;
}
using (StreamReader sr = File.OpenText(FILE_NAME))
{
String input;
while ((input=sr.ReadLine())!=null)
{
Console.WriteLine(input);
}
Console.WriteLine ("The end of the stream has been reached.");
sr.Close();
}
}
太过繁琐,不如php的简练。所以我发现自己还是喜欢php多一点。除非是很关心运行效率的地方。