|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
唉!都是钱闹的1.Swing和.net开发比较------从市场份额看.net开发主要占据大部分的中小型和中型的的桌面开发,原因是它封装了很多工具stream
importjava.io.*;
publicclassNewIODemo{publicstaticvoidmain(String[]args){try{//1.Readinginputbylines:BufferedReaderin=newBufferedReader(newFileReader(args[0]));Strings,s2=newString();while((s=in.readLine())!=null)s2+=s+"
";in.close();//1b.Readingstandardinput:BufferedReaderstdin=newBufferedReader(newInputStreamReader(System.in));System.out.print("Enteraline:");System.out.println(stdin.readLine());//2.InputfrommemoryStringReaderin2=newStringReader(s2);intc;while((c=in2.read())!=-1)System.out.print((char)c);//3.Formattedmemoryinputtry{DataInputStreamin3=newDataInputStream(//Oops:mustusedeprecatedclass:newStringBufferInputStream(s2));while(true)System.out.print((char)in3.readByte());}catch(EOFExceptione){System.out.println("Endofstream");}//4.Linenumbering&fileoutputtry{LineNumberReaderli=newLineNumberReader(newStringReader(s2));BufferedReaderin4=newBufferedReader(li);PrintWriterout1=newPrintWriter(newBufferedWriter(newFileWriter("IODemo.out")));while((s=in4.readLine())!=null)out1.println("Line"+li.getLineNumber()+s);out1.close();}catch(EOFExceptione){System.out.println("Endofstream");}//5.Storing&recoveringdatatry{DataOutputStreamout2=newDataOutputStream(newBufferedOutputStream(newFileOutputStream("Data.txt")));out2.writeDouble(3.14159);out2.writeBytes("Thatwaspi");out2.close();DataInputStreamin5=newDataInputStream(newBufferedInputStream(newFileInputStream("Data.txt")));BufferedReaderin5br=newBufferedReader(newInputStreamReader(in5));//MustuseDataInputStreamfordata:System.out.println(in5.readDouble());//Cannowusethe"proper"readLine():System.out.println(in5br.readLine());}catch(EOFExceptione){System.out.println("Endofstream");}//6.Readingandwritingrandomaccess//filesisthesameasbefore.//(notrepeatedhere)}catch(FileNotFoundExceptione){System.out.println("FileNotFound:"+args[1]);}catch(IOExceptione){System.out.println("IOException");}}}///:~
J2ME在手机游戏开发的作用也是无用质疑的。至于桌面程序,可能有人说java不行,界面不好看,但是请看看NetBeans和Eclipse吧,他们都是利用java开发的,而他们的界面是多么的华丽,所以界面决不是java的缺点。还有一个不得不提的优点就是大多java人员都挂在嘴边的java的跨平台性,目前这确实也是java优点之一。 |
|