如何在Java中获取INI文件的全部内容

时间:2017-07-11 08:07:03

标签: java web-services url ini ini4j

在webview中使用javafx的应用程序。

package ini;

import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Worker;
import javafx.concurrent.Worker.State;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.ScrollPane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
import javax.swing.JOptionPane;
import javax.swing.text.Document;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Node;
import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.LSSerializer;


public class Main extends Application {

  @Override
  public void start(final Stage stage)throws Exception {
    stage.setWidth(400);
    stage.setHeight(500);
    Scene scene = new Scene(new Group());

    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setContent(browser);

    webEngine.getLoadWorker().stateProperty()
        .addListener(new ChangeListener<State>() {
        private Object webView;
        private Object Title;

        private String query;

          @Override
          public void changed(ObservableValue ov, State oldState, State newState) {
            if (newState == Worker.State.SUCCEEDED) {
              stage.setTitle(webEngine.getLocation());
              String trgurl=webEngine.getLocation();
              System.out.println(trgurl);

              if(trgurl.contains("&ini=")) {
                JOptionPane.showMessageDialog(null, "got "+trgurl);
                String html = (String) webEngine.executeScript("document.documentElement.innerHTML");webEngine.executeScript("document.documentElement.outerHTML");
                System.out.println(html);
                try {
                  CreateFileExample createFileExample;
                  createFileExample = new CreateFileExample(trgurl);
                } catch (IOException ex) {
                   Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
                }
              } else {
                JOptionPane.showMessageDialog(null, "got nothing");
              }

            }

          }

        });

    webEngine.load("url");
    webEngine.load("url");
    scene.setRoot(scrollPane);

    stage.setScene(scene);
    stage.show();

  }

  public static void main(String[] args) throws MalformedURLException {
    launch(args);
    try {
      String webEngineLocation = webEngine.getLocation();
      URL url = new URL(webEngineLocation);
    } catch (MalformedURLException e) {
    }
   }

   private static class webEngine {

     private static String getLocation() {
       throw new UnsupportedOperationException("Not supported yet."); 
     }

     public webEngine() {
     }
   }
 }

由于我在密钥/值对中获取此ini文件的程序尚不完整,所以任何人都可以告诉如何获取密钥/值对中的ini的完整数据,以便如何获取我应该知道为什么数据丢失,提前谢谢。 它包含键值[app]主机名= niti 仅举例来说。

0 个答案:

没有答案