经纬坐标(BLH)数据创建.kml文件小工具设计 Java版

 技术背景

  KML,是
image

  核心部分

复制代码
  1 package main;  2   3 import java.io.BufferedWriter;  4 import java.io.File;  5 import java.io.FileNotFoundException;  6 import java.io.FileOutputStream;  7 import java.io.FileReader;  8 import java.io.FileWriter;  9 import java.io.IOException; 10 import java.io.LineNumberReader; 11 import java.io.PrintStream; 12 import javax.swing.JFileChooser; 13 import javax.swing.JLabel; 14  15 public class BlhToKml { 16  17 	/**  18 	 * @param args  19 	 */ 20 	public static String InputFilePath; 21 	public static String OutputFilePath; 22 	@SuppressWarnings("static-access") 23 	public static void main() throws IOException{ 24 		JFileChooser jfc=new JFileChooser(); 25 		jfc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES ); 26 		jfc.showDialog(new JLabel(), "选择文件"); 27 		File file = jfc.getSelectedFile(); 28 		if(file == null){ 29 			return; 30 		} 31 		String FilePath = file.getAbsolutePath(); 32 		InputFilePath=FilePath; 33 		OutputFilePath=InputFilePath; 34 		if(OutputFilePath.indexOf(".")>=0) 35 	     { 36 			OutputFilePath = OutputFilePath.substring(0, OutputFilePath.lastIndexOf(".")); 37 	     }else{ 38 	    	return; 39 	     } 40 		OutputFilePath=OutputFilePath+".kml"; 41 		//System.out.println(OutputFilePath); 42 		WriteHeadInformationToFile1(); 43 		WriteHeadInformationToFile2(); 44 		ReplacePointInformation(); 45 		WriteEndInformationToFile(); 46 		TipFrame TF = new TipFrame(); 47 		TF.tishifu("已经转换完成!"); 48 	} 49 	//将标题写入到指定路径下的文本内 50 	public static void WriteHeadInformationToFile1() { 51 		String filePath = OutputFilePath; 52 		try { 53 			File file = new File(filePath); 54             PrintStream ps = new PrintStream(new FileOutputStream(file)); 55             
                    
50000+
5万行代码练就真实本领
17年
创办于2008年老牌培训机构
1000+
合作企业
98%
就业率

联系我们

电话咨询

0532-85025005

扫码添加微信