testtracksample.java

来自「此程序都是企业级 的数据库开发程序 全面揭示了JAVA对数据库的操作」· Java 代码 · 共 51 行

JAVA
51
字号
package sql99;

import javax.swing.*;
import java.io.*;
import java.sql.*;
import connections.*;

public class TestTrackSample {
  public static void main(String[] args) {
    String filename = 
      chooseFile("Select the file to be stored in the database");
    System.out.println("Filename=[" + filename + "]");

    TrackSample ts = null;
    if (!filename.equals("")) {
      File file = new File(filename);
      ts = new TrackSample(1, 1, file);
      ts.create();
    } 

    filename = chooseFile("Select the file where the binary data " +
                          "will be written");
    System.out.println("Filename=[" + filename + "]");
    if (!filename.equals("")) {
      File file = new File(filename);
      ts = new TrackSample(1, 1, file);
      ts.retrieve();
    } 

    System.exit(0);
  } 

  static String chooseFile(String title) {

    // Use a JFileChooser to let the user select the file to be
    // read and written to the media table
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle(title);
    int returnVal = chooser.showOpenDialog(null);
    String pathname = "";
    if (returnVal == JFileChooser.APPROVE_OPTION) {
      pathname = chooser.getSelectedFile().getAbsolutePath();
    } else {
      System.out.println("No file selected");
    } 

    chooser = null;
    return pathname;
  } 
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?