技术背景
核心部分
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


