java中文件操作大全
一.获得控制台用户输入的信息<div style="padding-right: 5.4pt; padding-left: 5.4pt; background: #e6e6e6 0% 50%; padding-bottom: 4px; width: 95%; padding-top: 4px;">http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif/** *//**获得控制台用户输入的信息
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif * @return
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif * @throws IOException
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif */
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gifhttp://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif public String getInputMessage() throws IOException...{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif System.out.println("请输入您的命令∶");
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif byte buffer[]=new byte[1024];
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif int count=System.in.read(buffer);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif char[] ch=new char-2];//最后两位为结束符,删去不要
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif for(int i=0;i<count-2;i++)
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif ch=(char)buffer;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif String str=new String(ch);
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif return str;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif }
页:
[1]