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

📄 numsproducer.java

📁 大整数相乘
💻 JAVA
字号:

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Random;

/*
 * Created on 2006-11-13
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

/**
 * @author Shenjun
 *
 * NumsProducer类主要封装了产生大整数的方法。
 */
public class NumsProducer {
	
	/**
	 * 
	 */
	public NumsProducer() {
     
	
	}
	
	
	/**
	 * 该方法用于产生大整数
	 * @param out 指定保存大整数的文件
	 * @param N   指定大整数的位数
	 */
	public void produceNums(String out,int N)
	{
		
		if(N<=0)return;
		try {
			output=new FileOutputStream(out);
			int i=0;
			int tempRandom;
			while(i<N){
			    tempRandom=r.nextInt(10);
				//System.out.print(" "+tempRandom);
				try {
					output.write(tempRandom);
					i++;
				} catch (IOException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
			output.close();
				// TODO Auto-generated constructor stub
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		
	}
	/*
	private void GetNums(String in) {
		try {
			FileInputStream input=new FileInputStream(in);
			try {
				System.out.println("Get the NUMS!!");
				int t=input.read();
				while (t!=-1) {
					//addToHead(t);
					
					System.out.print(" "+t);
					t=input.read();
				}
				input.close();
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
	}*/
	private FileOutputStream output;
	private Random r=new Random();
	
	public static void main(String[] args) {
		
	}
}

⌨️ 快捷键说明

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