<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[Heck's  Blog]]></title> 
<link>https://www.heckjj.com/index.php</link> 
<description><![CDATA[一瞬间的决定，往往可以改变很多，事实上，让自己成功的往往不是知识，是精神！ 如果你总是为自己找借口，那只好让成功推迟。执行力，今天！]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[Heck's  Blog]]></copyright>
<item>
<link>https://www.heckjj.com/post//</link>
<title><![CDATA[java实现接收从键盘上输入的数据保存到文本文件]]></title> 
<author>Heck &lt;@hecks.tk&gt;</author>
<category><![CDATA[编程杂谈]]></category>
<pubDate>Thu, 09 Sep 2010 17:44:52 +0000</pubDate> 
<guid>https://www.heckjj.com/post//</guid> 
<description>
<![CDATA[ 
	<textarea name="code" class="java" rows="15" cols="100">import java.io.BufferedReader;
import java.io.InputStreamReader;
/**
 * 测试从键盘读取用户的输入,关键类为Scanner
 */
public class TestInput &#123;
&nbsp;&nbsp;public static void main(String[] args) &#123;
&nbsp;&nbsp;&nbsp;&nbsp;try&#123;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.print("Please input a number:");&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String str=reader.readLine();&nbsp;&nbsp;//获取字符串&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; str = str.trim();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String[] arr = str.split("&#92;&#92;s+");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(int i =0;i<arr.length;i++) &#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; arr[i]=arr[i].trim();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(arr[i]+"&nbsp;&nbsp;===&nbsp;&nbsp; "+Math.log10(Integer.valueOf(arr[i])));
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;catch (Exception e)&#123;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e.printStackTrace();&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println("fail");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;&nbsp;&nbsp; 
&nbsp;&nbsp;&#125;
&#125;</textarea><br/><textarea name="code" class="java" rows="15" cols="100">import java.util.Scanner;
/**
 * 测试从键盘读取用户的输入,关键类为Scanner
 * @author Administrator
 */
public class TestInput &#123;
&nbsp;&nbsp;public static void main(String[] args) &#123;
&nbsp;&nbsp;&nbsp;&nbsp;Scanner s = new Scanner(System.in);
&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("请输入你的姓名：");
&nbsp;&nbsp;&nbsp;&nbsp;String name = s.nextLine();
&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("请输入你的年龄：");
&nbsp;&nbsp;&nbsp;&nbsp;int age = s.nextInt();
&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("请输入你的工资：");
&nbsp;&nbsp;&nbsp;&nbsp;float salary = s.nextFloat();
&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("你的信息如下：");
&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("姓名：" + name + "&#92;n" + "年龄：" + age + "&#92;n" + "工资："
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+ salary);
&nbsp;&nbsp;&#125;
&#125;</textarea><br/><br/><textarea name="code" class="java" rows="15" cols="100">import java.io.*;

public class Test &#123;
&nbsp;&nbsp;public static void main(String[] args) throws IOException &#123;
&nbsp;&nbsp;&nbsp;&nbsp;BufferedReader buf = new BufferedReader(
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new InputStreamReader(System.in));
&nbsp;&nbsp;&nbsp;&nbsp;BufferedWriter buff = new BufferedWriter(new FileWriter("D:/userinfo.txt"));
&nbsp;&nbsp;&nbsp;&nbsp;String str = buf.readLine();
&nbsp;&nbsp;&nbsp;&nbsp;while (!str.equals("exit")) &#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buff.write(str);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buff.newLine();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buff.flush();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;str = buf.readLine();
&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&nbsp;&nbsp;buf.close();
&nbsp;&nbsp;&nbsp;&nbsp;buff.close();
&nbsp;&nbsp;&#125;
&#125;</textarea><br/>Tags - <a href="https://www.heckjj.com/tags/java%25E9%2594%25AE%25E7%259B%2598%25E8%25BE%2593%25E5%2585%25A5%25E5%2588%25B0txt%25E6%2596%2587%25E6%259C%25AC/" rel="tag">java键盘输入到txt文本</a>
]]>
</description>
</item><item>
<link>https://www.heckjj.com/post//#blogcomment</link>
<title><![CDATA[[评论] java实现接收从键盘上输入的数据保存到文本文件]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>https://www.heckjj.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>