Code example for PrintStream

Methods: format, println

0
			emitProlog(cal);
			didProlog = true;
		} 
 
		int hours = cal.get(Calendar.HOUR_OF_DAY);
		out.format(Locale.US, "B%02d%02d%02d%s%s%c%05d%05d%03d", hours, cal
				.get(Calendar.MINUTE), cal.get(Calendar.SECOND),
				degreeStr(latitude, true), degreeStr(longitude, false),
				is3D ? 'A' : 'V', (int) (is3D ? altitude : 0), // FIXME convert
																// altitudes 
				// correctly 
				(int) (is3D ? altitude : 0), // FIXME convert alts
				(int) groundSpeed);
		out.println();
 
		// Don't store vertical speed info until I can find an example data 
		// file. 
		if (!Float.isNaN(vspd) && false) {
 
			if (!hasJRecord) {
				// less frequent extension - vario data 
				out.println("J010812VAR");
				hasJRecord = true;
			} 
 
			out.format(Locale.US, "K%02d%02d%02d%03d", hours,
					cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND),
					(int) vspd * 10);
			out.println();
		} 
	} 
 
	/** 
	 * Do the heavy lifting necessary to spit out a file header 
	 */ 
	private void emitProlog(Calendar cal) {
 
		out.println("AXGG"+versionString); // AFLY06122 - sect 3.1, A=mfgr info,
		// mfgr=FLY, serial num=06122 
 
		// sect 3.3.1, H=file header 
		String dstr = String.format(Locale.US, "HFDTE%02d%02d%02d",
				cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.MONTH) + 1,
				(cal.get(Calendar.YEAR) - 1900) % 100); // date
 
		out.println(dstr); // date
 
		out.println("HFFXA100"); // accuracy in meters - required
		out.println("HFPLTPILOT:" + pilotName); // pilot (required)
		out.println("HFGTYGLIDERTYPE:" + gliderType); // glider type (required)
		out.println("HFGIDGLIDERID:" + pilotId); // glider ID required
		out.println("HFDTM100GPSDATUM:WGS84"); // datum required - must be wgs84
		out.println("HFGPSGPS:" + android.os.Build.MODEL); // info on gps
		// manufacturer 
		out.println("HFRFWFIRMWAREVERSION:" + versionString); // sw version of app
		out.println("HFRHWHARDWAREVERSION:" + versionString); // hw version
		out.println("HFFTYFRTYPE:Geeksville,Gaggle"); // required: manufacturer
		// (me) and model num 
 
		// sect 3.4, I=fix extension list 
		out.println("I013638GSP"); // one extension, starts at byte 36, ends at
		// 38, extension type is ground speed (was TAS) 
	} 
 
	/** 
	 * Add standard IGC prologue