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

📄 gformat.java

📁 一个用JAVA 写的程序
💻 JAVA
字号:
import java.text.*;

public class GFormat
//a class holding static methods for 
//formatting purposes
{
	public static String padRight(String s, int n)
	//if s has fewer than n characters then 
	//adds enough spaces to the right of s to make up to n
	{
		String ns =s;
		while (ns.length()<n)
			ns=ns+' ';
		return ns;
	}
	
	public static String padLeft(String s, int n)	
	//if s has fewer than n characters then 
	//adds enough spaces to the left of s to make up to n
	{
		String ns =s;
		while (ns.length()<n)
			ns=' '+ns;
		return ns;
	}
	
	public static String padLeftZeroes(int num, int n)
	{
		String ns ="" + num;
		while (ns.length()<n)
			ns='0'+ns;
		return ns;	
	}
	
	public static String fixDecimalPlaces(double d, int n)
	//returns a String representation of d rounded to 
	//n decimal places.  If necessary 0's are added on right
	{
		NumberFormat nf = NumberFormat.getInstance();
		nf.setMaximumFractionDigits(n);
		nf.setMinimumFractionDigits(n);
		return nf.format(d);
	}
	
}

⌨️ 快捷键说明

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