public static String fixedWidthDoubletoString(double x,int w,int d){
  java.text.DecimalFormat fmt=new java.text.DecimalFormat();
  fmt.setMaximumFractionDigits(d);
  fmt.setMinimumFractionDigits(d);
  fmt.setGroupingUsed(false);
  String s=fmt.format(x);
  while (s.length() < w) {
    s=" " + s;
  }
  return s;
}

public static String fixedWidthDoubletoString ( double x , int w , int d ) { java . text . DecimalFormat fmt = new java . text . DecimalFormat ( ) ; fmt . setMaximumFractionDigits ( d ) ; fmt . setMinimumFractionDigits ( d ) ; fmt . setGroupingUsed ( false ) ; String s = fmt . format ( x ) ; while ( s . length ( ) < w ) { s = " " + s ; } return s ; }
format double with fw . d .
