Open html file from Applet

Hi,
I need to open html file from applet, the html file is placed in my local system, it is not open. the code is below, please can u tell where i did wrong.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
<applet code="Resource.class" width="400" height="400"></applet>
public class Resource extends Applet implements ActionListener
Button b = null;
public void init(){
b= new Button("Click");
add(b);
b.addActionListener(this);
public void actionPerformed(ActionEvent ae){
try
URL adress = new URL(getDocumentBase(), "html_code.htm");
getAppletContext().showDocument(adress, "_blank");
System.out.println("Execut inside"+adress);
}catch(MalformedURLException e){
System.out.println("Eror in Display");
}

Don't cross post
http://forum.java.sun.com/thread.jspa?threadID=633500

Similar Messages

  • Opening HTML file from java GUI

    Can someone please tell me how I can open a HTML file in Internet Explorer from a Java GUI,
    I have an asssignment I am doing for college and I was toying with the idea of putting in helpfiles, for the program, can anyone tell me the easiest way of apcomplishing this???
    Thanks in advance for your help,
    Kaspah

    Although this should answer your question, there are other (cross platform) ways to do what you want. As opposed to your "must have internet explorer" solution. Swing has a built in html viewer you might use, for example. I've been doing some reading on java/xml solutions. I don't consider myself knowledgeable enough (yet) to comment on that solution though. A delimited text file would be another solution. Useing that solution you could treat the file like a set of parrallel arrays on the hard drive and disply your text on pre-formated labels. Anyway, here is a link to you answer......
    http://java.sun.com/products/jdk/1.2/docs/api/java/lang/Runtime.html#exec(java.lang.String)
    Ron_W

  • Can't open HTML files from local or remote location

    Hello Experts,
    I've tried deleting my remote location, and adding it back
    again several times and I still can't open any HTML files. I can
    check out the pages, and check them back in, but nothing shows up
    on the screen. Does anyone know what may be causing this? I'd
    really like to update my website soon. If I click on the web images
    they open up in my photoshop, it's just the Dreamweaver HTML
    portions that won't open up.
    Thank you,
    Calie

    > Unfortunately I can't seem to get any of the pages open
    to check out the code
    > view.
    CLARIFY please.
    You said you open them, but design view is blank.
    The file is either open or not open
    Is the file open? And design view is blank? Or is the file
    NOT open and
    there are error messages?
    If the is open, even if empty design view There should be
    something in code
    view.
    some not random attempts at fixing this:
    open dreamweaver.
    Open this site.
    DON'T open any files.
    open find and replace
    Find in Source Code, sitewide:
    <!-- -->
    replace with: [nothing]
    reason: not much of one, but I've never seen an empty html
    comment. It
    doesn't need to be there.
    Then, i'm trying to think of a way to fix this badly nested
    bold tag
    <p><b>
    <a href="about-me.html">ABOUT ME</a> |
    <a href="contact.html">CONTACT</a> |
    <a
    href="
    http://blog.loveBaRKLee.com/">BLOG</a>
    </p></b>
    the closing </b> needs to be moved to before the
    closing paragraph tag.
    My next guess is that it's a css problem-
    http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fwww.lovebarkle
    e.com%2Fdog-bed-accents.html&profile=css21&usermedium=all&warning=1&lang=en
    moz-radius
    http://validator.w3.org/check?uri=http%3A%2F%2Fwww.lovebarklee.com&charset=%
    28detect+automatically%29&doctype=Inline&group=0
    Fix the errors, clarify if the file does or doesn't open in
    dreamweaver, if
    it opens and design view is blank or if it doesn't open and
    crashes the app.
    moosepucky.
    Alan
    Adobe Community Expert, dreamweaver
    http://www.adobe.com/communities/experts/

  • Execute html file from java code - urgent!!!

    Hi,
    I need help!!
    My application should open html file that located in my computer
    it should be open when some line in JList was choosen
    my question is: How can I open html file from my application
    I work with window XP
    I tried this one :
    Runtime.getRuntime().exec(cmdLine);
    but it doesn't work
    the exeption was: CreateProccess
    Please help! it's urgent!!!!

    http://forum.java.sun.com/thread.jsp?forum=31&thread=497600

  • When i open any .HTML file from my computer it is not opening in firefox. Only a blank New Window Opens. Facing this problem since the firefox has updated.

    Whenever i try to open any HTML file from my computer, it opens a new firefox window which is blank. Facing this problem after the new update. please fix this problem

    I found that after Firefox v29, a LOT of my settings and<BR>
    add-ons were changed / reset. Try this;
    '''''[https://support.mozilla.org/en-US/kb/troubleshoot-firefox-issues-using-safe-mode Start Firefox in Safe Mode]'''''
    <BR>While you are in safe mode;<BR>
    '''''Firefox Options > Advanced > General'''''.<BR>
    Look for and turn off '''Use Hardware Acceleration'''.<BR>
    Then check ALL of your settings. Browser and add-ons. Then restart.

  • When I open an html file from the desktop all I see is source code rather than webpage.

    I have tried clearing the cache and reading other questions similar. I have a mac and am opening these files from the desktop, not a server or anything so It's incredibly annoying that firefox wont open them as html files even though that is what they are saved as. Also there is no .txt after them. They are purely .html files.

    Try to delete the mimeTypes.rdf file in the Firefox profile folder to reset all file actions.
    *http://kb.mozillazine.org/mimeTypes.rdf
    *http://kb.mozillazine.org/File_types_and_download_actions#Resetting_download_actions
    Firefox 16.0.2 is the last version that works on an Intel Mac with the OS X 10.5 operating system.
    * https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/16.0.2/mac/
    Another option to consider is to install the last Firefox 10.0.x ESR version as that version is more recent than the Firefox 16.0.2 version.
    * https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/10.0.12esr/

  • Adf11g how to open pdf or html files from  webservice

    hi all,
    adf11g how to open pdf or html files from webservice .

    Hi,
    This is standard functionality, that you can read more about in the OLM User Manual. You can upload the files to an OLM content server or to any other content server that can be accessed with a URL.
    Regards Anders Northeved

  • How Can i open Html file in a Browser from Jar file

    Hi
    i am having Html help files inside my Jar file ... if i use
    getclass().getRource("\lib\start.html");
    it is not opening ... so i have to ship seperate folders for html files along with jar files.... can anyone give the solution to have(open) html files inside the jar file and to open then in a default browser of any OS
    Regards
    Ganesan S

    the follwing method i have used to open html file ...
    so to access html file i am shipping resources folder with jar file ..
    private void openHtmlPages(String pageName) {
         String cmd[] = new String[2];
         String browser = null;
         File file = null;
         if(System.getProperty("os.name").indexOf("Linux")>-1) {
              file = new File("/usr/bin/mozilla");
              if(!file.exists() ) {
              }else     {
                   browser = "mozilla";
         }else {
              browser = "<path of iexplore>";
         cmd[0] = browser;
         File files = new File("");
         String metaData = "/resources/Help/Files/"+pageName+".html"; // folder inside jar file
         java.net.URL url = this.getClass().getResource(metaData);
         String fileName = url.getFile();
         fileName = fileName.replaceAll("file:/","");
         fileName = fileName.replaceAll("%2520"," ");
         fileName = fileName.replaceAll("%20"," ");
         fileName = fileName.replaceAll("jarfilename.jar!"," ").trim();
         cmd[1] = fileName;     
         try{
              Process p = Runtime.getRuntime().exec(cmd);
         }catch(java.io.IOException io){
                   //Ignore
    can anyone give me the solution..???
    Regards
    Ganesan S

  • How do I open an HTML file from my hard drive?

    Hello FireFox,
    I develop applications in JavaScript and need to test them in the three major
    browsers including FireFox. In the older version one would click on the FireFox logo and
    go to New Page (New Tab?) and then File. Recently downloaded FireFox 30.0 and there
    does not seem to be New Page option. I see New Window but it does not give me an option
    for opening a file from the hard drive.
    Thanks
    Allen in Dallas

    Hi!
    There are a few ways to open files in Firefox. The easiest is '''CTRL''' + '''O'''. Another easy option is to click Menu > Open File (if it's not there, you'll have to enter the Customize menu to drag it in).
    <hr>
    Happy coding!

  • How to create a small HTML-file in Applet

    What i wan't to do is as follows:
    1. In an applet i create a string containing a small HTML-file. Its contents depends on what the user chose in the applet.
    2. then i wan't to redirect the browser to that HTML-file. appletcontext.showDocument(URL) could be used.
    The problem is how can i create an URL to a string which is only in memory.
    Writing the string to a file and then creating URL to it poses problems, as we all know, writing files from applets is difficult.
    Any help would be appreciated.

    Here is how you do it:
    1) use the JSObject (you may have to import
    netscape.javascript.JSObject depending on the
    version of your SDK) to open a window with an empty
    URL, a title , and a _blank or _self
    target.
    2) use the JSObject document.write to write the HTML
    string to the window that you opened in #1 above
    3) close the document.
    If you need further assistance, post your code and I
    can modify it for you or if you want, I can whip up a
    small demo applet for you to try.
    ;o)
    V.V.Thanks!! Your post has been very helpful. One question though, I suppose the client has to have a java-plug-in installed in his/her web-browser, is that right?

  • I am trying to open PDF files from safari, but when I click on them they open in a separate window and the information is encrypted. Any ideas on how to get them to open them in Adobe? Any help please!

    I am trying to open PDF files from safari, but when I click on them they open in a separate window and the information is encrypted. Any ideas on how to get them to open them in Adobe? Any help please!

    The pdf is loading as html code. If you save it, it will download as :
    605124.pdf.html
    Change the extension to .pdf
    And it opens and works perfectly, I just tested it:
    Use this link to download it automatically:
    http://saladeaula.estacio.br/arquivo.asp?dir=00/1020624/605124.pdf&num_seq=59828 4

  • Open a file from anywhere - with credentials?

    Hi;
    Is there a way to open a file from anywhere where I give the uri and uname/password and it gives me back a Stream to read? Including:
    1. ftp - with/without credentials
    2. http - anon, basic, digest, & windows authentication
    3. REST where you must do basic on the first request (anon returns an error message as an html page).
    4. share on the same domain - requires a different user's credentials.
    5. share on a different domain
    6. share on a workgroup computer
    7. share on a non-Windows server
    8. ???
    thanks - dave
    Edited by: [email protected] on Sep 15, 2010 2:04 PM

    [email protected] wrote:
    Hi;
    I just wanted to add the use case so you would understand why we need to handle all cases. I suggest that you actually ask customers what they want initially instead of assuming that you need all of them initially.
    We have a reporting system we sell and one thing users can do is import images from an external source. Some users put their images on a web or FTP server requiring credentials. Others put it on a server that requires credentials. And we're now getting requests to pull from SharePoint.Fine. So you have the following task that has the following steps.
    1. Define source of image and where to store it.
    2. Create retriever based on 1.
    3. Run instance of 2
    4. Log errors from 3 or put retrieved file into location specified by 1.
    In the above step 2 is a plug in that represents different ways of retrieving information.
    And expanding on something that was said before you have a HUGE task in front of you in terms of supporting everything that you list above.
    For example using only ftp these are some of the things I see.
    1. There are at least three types of secure "ftp" servers. The protocol for handling security is different for each.
    2. Although FTP is a protocol the implementation of how the servers work can be substantially different. For general handling the will likely require scripting for each targetted server.
    3. Locations on FTP servers not necessarily simple. Examples.
    ...a. Login to server. Cd to a directory. Get a file which has a date as part of the name.
    ...b. Login to a server. Cd to a directory with a timestamp in the name. Get a file.
    ...c. Login to a server. Get a file which has a random name based on the last creation timestamp of each file.
    Note that FTP is actually easier than some of the other cases.
    And in the above I didn't deal with any of the possible errors.

  • Can't import/open HTML files in Fireworks CS4

    I'm trying to import/open HTML files into Fireworks CS4 to do some redesigning. I inherited the job of redoing my companies website and we believe the person who created our website created the site using Dreamweaver 8. Unfortunatley that person moved on to a new job across the country and we can't ask him exactly how he created our website.
    When I try to open some of the HTML files in FW I get the message: "Could not open the file....Fireworks could not find an HTML table in this file". Next I tried creating a new, very simple HTML page in Dreamweaver CS4 that contains just a few lines of text and 1graphic (we just bought the CS4 web suite). Again, I get the same error.
    Other files give me a slightly different error message when trying to open them in FW, "The HTML document contains one or more images with absolute web addresses for the source. Fireworks cannot handle these images. --click OK-- (next error message) Could not open the file. Fireworks has encountered a problem with the HTML in this table. Verify that the HTML is valid"... and then it closes and nothing loads into FW. Bummer.
    I've searched on these forums and can't find any solutions to this problem although I found a few people experiencing the same problem.
    Do I need to do something to the Dreamweaver created HTML's to get them to open in FW? Any help would be appreciated.

    Fireworks is a graphics editor that can export code; it is not an HTML/code editor.
    If you have exported HTML from Fireworks, you ought to be able to re-import that, but I would think most people who use Fireworks exported code would just modify their Fireworks document and re-export. (Fireworks' code is not robust and it is only intended for mockups and prototypes. Fireworks is not intended for developing and maintaining live Web sites; Dreamweaver is.)
    If your developer used Dreamweaver, then I really don't expect that Fireworks would be able to import that, nor any code that isn't in exactly the format that it can export. If you know your developer used Fireworks, then you need to look for .png files. Fireworks uses an enhanced version of the PNG format for its native document format.
    If you are making small adjustments to your site, then you might be better off working in Dreamweaver. If you're doing a site re-design, then Fireworks is an excellent tool for laying out your design and producing your graphics, but you will, at some point, need to move over to Dreamweaver for coding.

  • Unable to open html file in document library without saving first

    I've uploaded a bunch of HTML files from a DVD to a document library on our Sharepoint 2013 Enterprise server. When I try to open one of the html files it wants to save the file instead of opening it. If I choose to open the document library in Explorer
    I'm able to open the html files w/o issue.
    What's causing this? I know there is an option to set the file handing to permissive, but I'd rather not do that.

    Carl,
    See this link - http://sharepoint.stackexchange.com/questions/39020/how-do-i-prevent-sharepoint-from-asking-to-download-html-files-to-my-local-machi
    The allowed mime types are defined in theSPWebApplication.AllowedInlineDownloadedMimeTypes
    Property
    Here is small PowerShell utility function I use:
    function Add-SPAllowedInlineDownloadedMimeType{
    [CmdLetBinding()]
    param(
    [Parameter(Mandatory=$true, Position=0, ValueFromPipeLine=$true)]
    [Microsoft.SharePoint.PowerShell.SPWebApplicationPipeBind]$WebApplication,
    [Parameter(Mandatory=$true, Position=1)]
    [string]$MimeType
    process{
    $actualWebApp = $WebApplication.Read()
    if ($actualWebApp.AllowedInlineDownloadedMimeTypes -notcontains $mimetype)
    Write-Host "Adding MIME Type..."
    $actualWebApp.AllowedInlineDownloadedMimeTypes.Add($mimetype)
    $actualWebApp.Update()
    Write-Host "Done."
    } Else {
    Write-Host -ForegroundColor Green "MIME type is already added."
    And it can be used like this:
    Add-SPAllowedInlineDownloadedMimeType -WebApplication http://mywebapp -MimeType "text/html"
    Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply.

  • Playing an audio file from applet

    Hi friends,
    I have a problem to be solved .
    Please help me.
    I have to play an audio file from applet.When the applet loads it shold start playing .There is a progress bar in the applet it shold alsomove corresponding to that.
    How can i do that.Give me an idea.
    I know nothing about jmf.
    I am using j2sdk1.4,windows 2000 server.

    Andrew,
    Forgive my naivety, but i struggle with JAVA! I am desperately trying to create a JAVA plugin to SERVOY and have to date been successful with a few things. Record, Playback, convert to .spx.
    I am really struggling with implementing a rewind and fastforward function of the type you have. I thought it would be easy, but it appears not.
    At the bottom is the complete code from my class that is called by the servoy plugin wrapper,
    i had thought that adding some simple jump 500 ms would have been easy in something like this:
    public AudioStream js_FastForward (AudioStream as) throws IOException {
    !!! Line or two here to move the play head forward !!!
         AudioPlayer.player.start(as);
         return as;
    Can you give me any pointers to how i code that fast forward bit.
    many thanks
    David
    package com.d2e.MyPlugin;
    import com.servoy.j2db.scripting.IScriptObject;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.awt.Button;
    import javax.sound.sampled.*;
    import org.xiph.speex.*;
    import org.xiph.speex.spi.*;
    import  sun.audio.*;    //import the sun.audio package
    public class MyPluginProvider implements IScriptObject  {
          public void JSencode()
             throws IOException{
               /** Version of the Speex Encoder */
                final String VERSION = "Java Speex Command Line Encoder v0.9.7 ($Revision: 1.5 $)";
                /** Copyright display String */
                final String COPYRIGHT = "Copyright (C) 2002-2004 Wimba S.A.";
                /** Print level for messages : Print debug information */
                final int DEBUG = 0;
                /** Print level for messages : Print basic information */
                final int INFO  = 1;
                /** Print level for messages : Print only warnings and errors */
                final int WARN  = 2;
                /** Print level for messages : Print only errors */
                final int ERROR = 3;
                int printlevel = INFO;
                /** File format for input or output audio file: Raw */
                final int FILE_FORMAT_RAW  = 0;
                /** File format for input or output audio file: Ogg */
                final int FILE_FORMAT_OGG  = 1;
                /** File format for input or output audio file: Wave */
                final int FILE_FORMAT_WAVE = 2;
                int srcFormat  = FILE_FORMAT_OGG;
                int destFormat = FILE_FORMAT_WAVE;
                int mode       = -1;
                int quality    = 4;
                /** Defines the encoders algorithmic complexity. */
                 int complexity = 3;
                /** Defines the number of frames per speex packet. */
                 int nframes    = 1;
                /** Defines the desired bitrate for the encoded audio. */
                 int bitrate    = -1;
                /** Defines the sampling rate of the audio input. */
                 int sampleRate = -1;
                /** Defines the number of channels of the audio input (1=mono, 2=stereo). */
                 int channels   = 1;
                /** Defines the encoder VBR quality setting (float from 0 to 10). */
                 float vbr_quality = -1;
                /** Defines whether or not to use VBR (Variable Bit Rate). */
                 boolean vbr    = false;
                /** Defines whether or not to use VAD (Voice Activity Detection). */
                 boolean vad    = false;
                /** Defines whether or not to use DTX (Discontinuous Transmission). */
                 boolean dtx    = false;
              //HArd code src format and dest
               // private String srcPath ="junk.wav";
              srcFormat = FILE_FORMAT_WAVE;
              destFormat = FILE_FORMAT_OGG;
              //destPath="junk.spx";
             byte[] temp    = new byte[2560]; // stereo UWB requires one to read 2560b
             final int HEADERSIZE = 8;
             final String RIFF      = "RIFF";
             final String WAVE      = "WAVE";
             final String FORMAT    = "fmt ";
             final String DATA      = "data";
             final int WAVE_FORMAT_PCM = 0x0001;
             // Open the input stream
             DataInputStream dis = new DataInputStream(new FileInputStream("junk.wav"));
             // Prepare input stream
           //DP - Sort out the Wave File
               // read the WAVE header
               dis.readFully(temp, 0, HEADERSIZE+4);
               // Read other header chunks
               dis.readFully(temp, 0, HEADERSIZE);
               String chunk = new String(temp, 0, 4);
               int size = readInt(temp, 4);
               while (!chunk.equals(DATA)) {
                 dis.readFully(temp, 0, size);
                 if (chunk.equals(FORMAT)) {
                   typedef struct waveformat_extended_tag {
                   WORD wFormatTag; // format type
                   WORD nChannels; // number of channels (i.e. mono, stereo...)
                   DWORD nSamplesPerSec; // sample rate
                   DWORD nAvgBytesPerSec; // for buffer estimation
                   WORD nBlockAlign; // block size of data
                   WORD wBitsPerSample; // Number of bits per sample of mono data
                   WORD cbSize; // The count in bytes of the extra size
                   } WAVEFORMATEX;
                   if (readShort(temp, 0) != WAVE_FORMAT_PCM) {
                     System.err.println("Not a PCM file");
                     return;
                   channels = readShort(temp, 2);
                   sampleRate = readInt(temp, 4);
                   if (readShort(temp, 14) != 16) {
                     System.err.println("Not a 16 bit file " + readShort(temp, 18));
                     return;
                   // Display audio info
                   if (printlevel <= DEBUG) {
                     System.out.println("File Format: PCM wave");
                     System.out.println("Sample Rate: " + sampleRate);
                     System.out.println("Channels: " + channels);
                 dis.readFully(temp, 0, HEADERSIZE);
                 chunk = new String(temp, 0, 4);
                 size = readInt(temp, 4);
               if (printlevel <= DEBUG) System.out.println("Data size: " + size);
           //DP ENd sort wave file 
           //Now Choose the mode , we have a file sampled at 44100
                 mode = 2; // Ultra-wideband
             // Construct a new encoder
             SpeexEncoder speexEncoder = new SpeexEncoder();
             speexEncoder.init(mode, quality, sampleRate, channels);
             if (complexity > 0) {
               speexEncoder.getEncoder().setComplexity(complexity);
             if (bitrate > 0) {
               speexEncoder.getEncoder().setBitRate(bitrate);
             if (vbr) {
               speexEncoder.getEncoder().setVbr(vbr);
               if (vbr_quality > 0) {
                 speexEncoder.getEncoder().setVbrQuality(vbr_quality);
             if (vad) {
               speexEncoder.getEncoder().setVad(vad);
             if (dtx) {
               speexEncoder.getEncoder().setDtx(dtx);
             // Display info
             // Open the file writer
             AudioFileWriter writer;
             if (destFormat == FILE_FORMAT_OGG) {
               writer = new OggSpeexWriter(mode, sampleRate, channels, nframes, vbr);
             else if (destFormat == FILE_FORMAT_WAVE) {
               nframes = PcmWaveWriter.WAVE_FRAME_SIZES[mode-1][channels-1][quality];
               writer = new PcmWaveWriter(mode, quality, sampleRate, channels, nframes, vbr);
             else {
               writer = new RawWriter();
             writer.open("junk.spx");
             writer.writeHeader("Encoded with: " + VERSION);
             int pcmPacketSize = 2 * channels * speexEncoder.getFrameSize();
             try {
               // read until we get to EOF
               while (true) {
                 dis.readFully(temp, 0, nframes*pcmPacketSize);
                 for (int i=0; i<nframes; i++)
                   speexEncoder.processData(temp, i*pcmPacketSize, pcmPacketSize);
                 int encsize = speexEncoder.getProcessedData(temp, 0);
                 if (encsize > 0) {
                   writer.writePacket(temp, 0, encsize);
             catch (EOFException e) {}
             writer.close();
             dis.close();
            * Converts Little Endian (Windows) bytes to an int (Java uses Big Endian).
            * @param data the data to read.
            * @param offset the offset from which to start reading.
            * @return the integer value of the reassembled bytes.
           protected static int readInt(final byte[] data, final int offset)
             return (data[offset] & 0xff) |
                    ((data[offset+1] & 0xff) <<  8) |
                    ((data[offset+2] & 0xff) << 16) |
                    (data[offset+3] << 24); // no 0xff on the last one to keep the sign
            * Converts Little Endian (Windows) bytes to an short (Java uses Big Endian).
            * @param data the data to read.
            * @param offset the offset from which to start reading.
            * @return the integer value of the reassembled bytes.
           protected static int readShort(final byte[] data, final int offset)
             return (data[offset] & 0xff) |
                    (data[offset+1] << 8); // no 0xff on the last one to keep the sign
         AudioFormat audioFormat;
           TargetDataLine targetDataLine;
         public Class[] getAllReturnedTypes() {
              // TODO Auto-generated method stub
              return null;
         public String[] getParameterNames(String arg0) {
              // TODO Auto-generated method stub
              return null;
         public String getSample(String arg0) {
              // TODO Auto-generated method stub
              return null;
         public String getToolTip(String arg0) {
              // TODO Auto-generated method stub
              return null;
         public boolean isDeprecated(String arg0) {
              // TODO Auto-generated method stub
              return false;
         public String js_Record (String name){
              captureAudio();
              return "Started Recording " +name;
        public String js_StopRecord (String name) throws IOException{
             //new ActionListener(){
             //   public void actionPerformed(ActionEvent e)
                  //Terminate the capturing of input data
                  // from the microphone.
                  targetDataLine.stop();
                  targetDataLine.close();
              //  }//end actionPerformed
             //};//end ActionListener
                 // JSpeexEnc ("junk.wav","output.spx");
                  JSencode();
              return "Stop Records " +name;
        //Play audio file
        public AudioStream js_Playback (String name) throws IOException{
             InputStream in = new FileInputStream("junk.wav");
             AudioStream as = new AudioStream(in);        
             AudioPlayer.player.start(as);           
             return as;
        public AudioStream js_ContPlay (AudioStream as) throws IOException {
             AudioPlayer.player.start(as);           
             return as;
         //Stop Play
        public AudioStream js_Stop_Playback (AudioStream as) throws IOException{
             AudioPlayer.player.stop(as);
              return as;
         //This method captures audio input from a
        // microphone and saves it in an audio file.
        private void captureAudio(){
          try{
            //Get things set up for capture
            audioFormat = getAudioFormat();
            DataLine.Info dataLineInfo =
                                new DataLine.Info(
                                  TargetDataLine.class,
                                  audioFormat);
            targetDataLine = (TargetDataLine)
                     AudioSystem.getLine(dataLineInfo);
            //Create a thread to capture the microphone
            // data into an audio file and start the
            // thread running.  It will run until the
            // Stop button is clicked.  This method
            // will return after starting the thread.
            new CaptureThread().start();
          }catch (Exception e) {
            e.printStackTrace();
            System.exit(0);
          }//end catch
        }//end captureAudio method  
    //  This method creates and returns an
        // AudioFormat object for a given set of format
        // parameters.  If these parameters don't work
        // well for you, try some of the other
        // allowable parameter values, which are shown
        // in comments following the declarations.
        private AudioFormat getAudioFormat(){
          float sampleRate = 44100.0F;
          //8000,11025,16000,22050,44100
          int sampleSizeInBits = 16;
          //8,16
          int channels = 1;
          //1,2
          boolean signed = true;
          //true,false
          boolean bigEndian = true;
          //true,false
          return new AudioFormat(sampleRate,
                                 sampleSizeInBits,
                                 channels,
                                 signed,
                                 bigEndian);
        }//end getAudioFormat
        class CaptureThread extends Thread{
               public void run(){
                 AudioFileFormat.Type fileType = null;
                 File audioFile = null;
                 //Set the file type and the file extension
                 // based on the selected radio button.
                 //if(aifcBtn.isSelected()){
                  // fileType = AudioFileFormat.Type.AIFC;
                  // audioFile = new File("junk.aifc");
                // }else if(aiffBtn.isSelected()){
                 //  fileType = AudioFileFormat.Type.AIFF;
                 //  audioFile = new File("junk.aif");
                // }else if(auBtn.isSelected()){
                 //  fileType = AudioFileFormat.Type.AU;
                 //  audioFile = new File("junk.au");
                // }else if(sndBtn.isSelected()){
                //   fileType = AudioFileFormat.Type.SND;
                 //  audioFile = new File("junk.snd");
                // }else if(waveBtn.isSelected()){
                 fileType = AudioFileFormat.Type.WAVE;
                 audioFile = new File("junk.wav");
                // }//end if
                 try{
                   targetDataLine.open(audioFormat);
                   targetDataLine.start();
                   AudioSystem.write(
                         new AudioInputStream(targetDataLine),
                         fileType,
                         audioFile);
                 }catch (Exception e){
                   e.printStackTrace();
                 }//end catch
               }//end run
             }//end inner class CaptureThread
    }

Maybe you are looking for

  • No Internet Access thru VPN w/ Windows 8.1

    I had VPN working with Internet access & then all of a sudden it stopped working.  I suspect one of the Windows AUTO update changed something that made it stop working, but can not be sure. Per other blogs: I tried to temporary disable firewall and a

  • Sender email address verification

    During my recent DNS server outage (caused by XO DSL suddenly turning on filtering of port 53), I noticed something quite interesting with .Mac server and I am wondering if there is a way for Tiger server users to EASILY implement the same feature to

  • HT4059 If I make an iBook can I share it privately?

    Does anyone know if I make an iBook with iBook Author wil I be able to share just with my class? or do I have to place it in the store for them to have it and so can anyone else?

  • MySQL problem: can't get log-slow-queries to work

    I've edited added the requisite lines to /etc/my.cnf (which is being read on start up): [slowqueries] longquerytime = 5 log-slow-queries=/var/log/mysql-slow-queries.log And I've tried different locations for the log file, and I've chown'd it to :whee

  • Biztalk 2010 : Dynamic send Port Block : HTTP Adapter

    Hi I have a customer who makes an intensive use of the DefaultServerApp host instance. All of his applications use this instance for dynamic send port ( HTTP send adapter) The problem is sometimes the messages accumulate in the message queue of the H