⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 quote.java

📁 Typing fingers Typing programme
💻 JAVA
字号:
import java.util.*;
import java.io.*;
/**	This class has a method that returns a quote selected randomly from the file quotes.txt.
*/
class Quote{
	byte b[];
	Quote(){
		File f=new File(System.getProperty("user.dir")+"/text/quotes.abc");
		try{
			FileInputStream fis=new FileInputStream(f);
			b=new byte[(int)f.length()];
			fis.read(b);
			fis.close();
		}catch(Exception e){System.out.println(e);}
	}
	public String getQuote(){
		StringTokenizer st=new StringTokenizer(new String(b),""+'\r',false);
		int count=st.countTokens();
		int r=(int)(Math.random()*count);
		String quote="";
		for(int i=0;i<=r;i++)
			quote=st.nextToken();
		return quote.substring(1,quote.length());
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -