コード例 #1
0
  protected void getImages() {
    File directory = new File(this.saveDirectory);

    // BufferedImage img = null;

    images = new ArrayList<String>();
    if (directory.exists() && directory.isDirectory()) {
      // File[] files = directory.listFiles();
      String[] files = directory.list();

      for (int i = 0; i < files.length; i++) {
        // System.out.println(files[i]);
        // try {
        // if(files[i].getName().startsWith("cam"))
        if (files[i].startsWith("cam")) {
          // Windows spesific
          images.add(this.saveDirectory + "\\" + files[i]);
          /*
          img = ImageIO.read(files[i]);
          images.add(img);*/
        }
        // } catch (IOException e) {
        //	System.err.println("Failed on reading image. IOException.");
        // }
      }
    }

    System.out.println("Total image count = " + images.size());
    gotImages = true;
  }
コード例 #2
0
  public static void main(String args[]) throws Exception {

    // Take the path of the audio file from command line

    File f = new File("C:\\Users\\Larry\\AppData\\Local\\Temp\\jgoogle_tts-588881786930740869.mp3");
    // Create a Player object that realizes the audio
    final Player p = Manager.createRealizedPlayer(f.toURI().toURL());
    // Start the music
    p.start();
    // Create a Scanner object for taking input from cmd
    Scanner s = new Scanner(System.in);

    // Read a line and store it in st

    String st = s.nextLine();

    // If user types 's', stop the audio

    if (st.equals("s")) {

      p.stop();
    }
  }