Opening a txt file in my application

Hi all,
I am doing a desktop application.My application consist of a Jframe containing a Jtextarea and a Jbutton.what my app does is , it just writes the content of the jtextarea into a txt file and saves it with someother extension.Now on double clicking that txtfile , i want the file to get opened in my app and not in notepad or other things.Please help do that.
Thanks in advance
Ravisenan

Most probably, you can change the default application for a specific file extension using Windows APIs. You need to search for it. And if this can be done for a jar or class file, then you can register your application as the default application of your file type using JNI:
http://java.sun.com/docs/books/jni/
I dont think there is a platform independent solution for this.

Similar Messages

  • Opening a .txt file from an application

    I have an application that extends JFrame. There is a JButton that I want to use to open a file called
    "Instructions.txt."
    and the path to the file is
    "E:\CM0112\Code\Instructions.txt".
    I want to open this file using TextPad, I have tried the code
    Runtime.getRuntime.().exec()but I keep getting compile errors. Any hints would be greatly appreciated.

    try this code
    public class Open
      public static void main(String[] args)
         String line;
         EasyReader inFile = new EasyReader("instructions.txt")
         if(inFile.bad())
            System.out.println(" *** Can't Open instructions.txt *** ");
            System.exit(1);
         while((line = inFile.readLine()) != null)
           //implement your own code, each time loop executes
           //line is the next line in the file until it is null.
      Go to www.rfrank.net/cs-labs/1400-tasmania/EasyReader.java to find EasyReader.java

  • I want to open a txt file and output data through an AO-using DAQmx for PXI

    I have a PXI running a 8145RT CPU. I have a PX6040E Multifunction DAQ card installed in the PXI. I want to program an application where I open a txt file (existing in one of the the RT machines' folders), read the first row, and output its data through an AO channel. The drivers I should use is DAQmx v7.1, and the Labview RT v.7
    Any idea?

    What exactly are you having problems with? Reading a text file can be done a number of ways. Look at the File I/O palette and check out Read Lines From File or Read Characters From File. There are string to number conversion functions on the string palette (i.e. Scan From String). There are also numberous shipping examples on using DAQmx for analog out. If you have a specific problem or question, please post back with additional details.

  • How to write a code for  open new txt file in swing

    hai all,
    now i do one project in java.that project's GUI is Swing. But i don't known swing (basic).So how to write a code for open new txt file and "Open window " in menu item on swing.that means when i click the "New" on menu that time open a new txt file. open also like that type.
    plz give me that code ! very urgent
    Advance Thanks !
    RSK

    Swing Tutorial:
    http://java.sun.com/docs/books/tutorial/uiswing/index.html
    Since you don't know the basic of swing read the tutorial, it is for your own good because it is useless if we provide you with a code you don't even understand and how it works.
    If you want a menu read the tutorial about using menus and for opening a file read using JFileChooser.
    note: don't use the word urgent because it implies that your problem is more important than others.

  • Open all TXT files in Ultraedit

    Currently from the below code I am able to open a new empty file in ultraedit. But I need to open all *.txt files from a particular directory in ultraedit. Could anyone please help me with this.
    private void ueditButActionPerformed(java.awt.event.ActionEvent evt)
         java.awt.EventQueue.invokeLater(new Runnable()
              public void run()
                   try
                        Process procViewEd =Runtime.getRuntime().exec("C:\\Program Files\\UltraEdit\\UEDIT32.EXE ");
                   catch(IOException ioe)
                        System.out.println(ioe.getMessage());
    } For instance, when I click on ueditBut, all the txt files inside the path c:\temp should open in ultraedit.
    Message was edited by:
    Simmy
    Message was edited by:
    Simmy

    As an example, this code opens all of the .java files in the current directory using notepad:import java.io.*;
    public class Test {
        public static void main (String... parameters) throws IOException {
            File currentDir = new File (".");
            File[] javaFiles = currentDir.listFiles (new FilenameFilter () {
                public boolean accept (File parent, String filename) {
                    return filename.endsWith (".java");
            for (File javaFile: javaFiles) {
                Runtime.getRuntime ().exec (String.format ("cmd /c notepad %s", javaFile.getAbsolutePath ()));
    }

  • How to pull all the txt files from an application server to oracle server

    hi
    i got some 30 txt files on java application server. i have two questions
    1) can java guys will be able to move those files to some oracle directory that will be used by create external table command.
    2) can oracle do that using a stored procedure ..but then for it i think i have to create ftppkg and ftpbdy and call and connect each time...
    which one is better and why?
    regards
    raj

    Hi,
    You can create procedure to move file from application server to oracle server.
    Code for list all files in directory
    ops$tkyte@8i> GRANT JAVAUSERPRIV to ops$tkyte
      2  /
    Grant succeeded.
    That grant must be given to the owner of the procedure..  Allows them to read
    directories.
    ops$tkyte@8i> create global temporary table DIR_LIST
      2  ( filename varchar2(255) )
      3  on commit delete rows
      4  /
    Table created.
    ops$tkyte@8i> create or replace
      2     and compile java source named "DirList"
      3  as
      4  import java.io.*;
      5  import java.sql.*;
      6 
      7  public class DirList
      8  {
      9  public static void getList(String directory)
    10                     throws SQLException
    11  {
    12      File path = new File( directory );
    13      String[] list = path.list();
    14      String element;
    15 
    16      for(int i = 0; i < list.length; i++)
    17      {
    18          element = list;
    19 #sql { INSERT INTO DIR_LIST (FILENAME)
    20 VALUES (:element) };
    21 }
    22 }
    23
    24 }
    25 /
    Java created.
    ops$tkyte@8i>
    ops$tkyte@8i> create or replace
    2 procedure get_dir_list( p_directory in varchar2 )
    3 as language java
    4 name 'DirList.getList( java.lang.String )';
    5 /
    Procedure created.
    ops$tkyte@8i>
    ops$tkyte@8i> exec get_dir_list( '/tmp' );
    PL/SQL procedure successfully completed.
    ops$tkyte@8i> select * from dir_list where rownum < 5;
    FILENAME
    data.dat
    .rpc_door
    .pcmcia
    ps_data
    http://asktom.oracle.com/pls/asktom/f?p=100:11:3597961203953876::::P11_QUESTION_ID:439619916584

  • How can i make my form open a .txt file????

    hi every body,
    i need some help with that..
    i want my form to open a txt file, or at least copy that file from a specific source (windows folder) to a specific destination (another windows folder).
    note that this all will work on the server and the client.
    i hope to find some help.
    thnxxxxxx.
    plzzz i need help, it's a GRADUATE PRODUCT issue.
    sorry i'm not that strong, it gives me error with host command.
    Message was edited by:
    bondo2

    declare
    in_file Text_IO.File_Type;
    out_file Text_IO.File_Type;
    begin
    in_file := Text_IO.Fopen('salary.txt', 'r'); -- open file in read mode
    out_file := Text_IO.Fopen('bonus.txt', 'w'); -- open file in write mode
    end;
    for copy of the file:
    host(copy c:\test.txt c:\new_folder\);
    Hope this helps !!

  • Getting extra line after each record when opening a .txt file in excel

    Hi All,
    I have developed a program which downloads a file at application server.
    each record of file is 500 characters long & have CRLF at end.
    the file looks fine when opened in .txt format.
    however when i download it from application server to presentation server (using function "download to my computer"), & at presentation when i try to open it in excel format, it shows a blank line after every record.
    i don't want this blank line to appear if i download it & open it in excel.
    the file record is declared as char500 type.
    Please suggest how to deal with this.
    thanks in advance.
    Regards,
    Puja.

    Hi Puja,
    Check the file in the application server whether it has any gaps between the lines.
    Or else as you said if the file looks ok in .txt format, download the file in .txt and open the same file in excel (i.e. open with excel)
    Hope this sloves your problem.
    Regards,
    SB.

  • Open a txt file in a real time PXI target

    I want to open and read a txt file when targeting to a PXI, running a real time OS. The file is saved in a specific directory of the real time machine. When I run the typical Labview (version 7.1) examples there is alwasys an error message.

    Hi Matt,
    I hope you're doing well.  To be able to open files on the host from the RT target or vice-versa, you most likely will need to FTP the files back and forth between the two.  You need to have the files local on either machine to be able to edit or view them, and FTP is the simplest way to do so.  You can connect to your RT target via any standard FTP utility as discussed in this KnowledgeBase article.  I hope this is helpful.  Let us know if you have any additional questions though.
    Thaison V
    Applications Engineer
    National Instruments

  • Suddenly can not open a.TXT file... whahoppened?

    Hi,
    I am running latest OSX and my wife was in her account and trying to work. She downloaded a .TXT file that she wanted to open and when she tried it said she didn't have the necessary permissions. She is not an admin on this machine but this used to work in her account and now it doesn't and I can't figure out why!
    HELP

    Have your wife log onto to her account and navigate to the .txt file she downloaded. If it isn't already there, drag it to the Desktop so it's easier to work with. Now, select that file and click Command + I A window will open. Click the pop up menu and click Text Edit.
    Now, go back into the admin account and run Disk Utility and Repair Disk Permissions. Disk Utilities is in your Applications/Utility folder.
    Hope this helps,
    Carolyn

  • Open a pdf file located on Application Server from forms 10g

    Dear all,
    I want to open a pdf file which is stored in a folder on Application Server.
    I have the following codes but could not be able to open the file.
    1. host('rundll32 url.dll,FileProtocolHandler C:\REP012.pdf');
    in this code I mentioned the path on local machine which is okey.
    but the question is that how to open the file which is located in a folder on application server?
    the following code don't show and file or error:
    host('rundll32 url.dll,FileProtocolHandler /EMS/MANUALS/ACC001.PDF');
    This is the file on Application Server not on local machine.
    2. web.show_document('//EMS/MANUALS/ACC001.PDF/','_blank');
    This give HTTP 404 NOT FOUND error
    I think the problem is in path, how to mention the path of my Application Server file?
    Regards:
    Muhammad Nadeem

    Hi,
    Did you find a solution to this?
    We are running into the same problem where we need to open a file present on the application server (path /opt/webapps/applications/ISL/)
    When we try this from the local machine it works (path D:/forms) however it does not work while trying to open it from the application server.
    Regards,
    Pooja

  • Is there a way to create a button on the front panel that would automatically open the txt file data is being stored to?

    I am saving data read from FieldPoint to a .txt file. Is there a way to create a button on the front panel so that when the user pushes this button it automatically opens the .txt folder in notepad? I want to bypass the user having to find the file in the computer in order to open it.

    Hi jem,
    I suggest that you break this up into three seperate questions and re-post to this list. That way you get more ideas from others that may have better insites than myself.
    Re:the sysexec
    The Sysexec will allow you to execute a dos command. This is the equivalent of going to
    Start>>>Run
    What you should do is find the proper DOS command sysntax that is required to open a text file in notepad or your favorite editor. Once you know what a good DOS command is, you should pass that string to the Sysexec.VI. The Sysexec has an input that allows you to choose if the code waits for the command to complete or if it should just start the program and let it run in the background. Sysexec will open its own window to run the command you speci
    fiy.
    Ben
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Help Needed in opening a HTML File from swing application

    Hi,
    I am opening a HTML file in Internet Explorer from my swing application.
    I am using the code given below
    private final static String WIN_FLAG = "url.dll,FileProtocolHandler";
    private final static String WIN_PATH = "rundll32";
    String cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
    // url is HTML file Path
    Process p = Runtime.getRuntime().exec( cmd );
    The HTML file is opening up,but it always opens behind the swing application,that makes me every time to maximize the HTML file after it being opened up.
    I want to open it in front of the Swing Application.
    Any Help Please ?
    - Manikandan

    Check your Application's JFrame properties (may be ur Frame is set to be in top position ,always),and also check running your application in some other OS.

  • I want to open a .txt file in the Notepad editor

    Dear all,
    In my java program, when i click on a menu item, i need a .txt file to be opened in the notepad editor. Can someone please send to tell me how?
    Thanks

    Is not very portable to specify the absolute path of notepad. If you pass the program to your friend it might not run!
    I usually specify only the document.txt and the shell exe file (in windows xp cmd.exe), then the operating system think how to open the file. You can setting the operating system to open all the .txt file with notepad. It is very easy.
    The your .txt document in your classpath, so is relative and not absolute.
    Here the code:
    String cmd = "cmd.exe /c start ";
                   String file = "mydocuemnt/manual.txt";
                  try {
                        Runtime.getRuntime().exec(cmd + (ClassLoader.getSystemResource(file)).toString());
                   } catch (IOException ee) {
                        JOptionPane.showMessageDialog(null, "The document dosn't exist!",
                                  "Document not finded!", JOptionPane.ERROR_MESSAGE);
                        ee.printStackTrace();
                   } bye

  • Defect:  Sometimes opened sql/txt files are unreadable in worksheet.

    I haven't pinpointed the exact sequence of events yet. Sorry.
    I work on two different machines. One: 64bit running Vista. Two: 32bit running XP.
    They have the same fonts and operating system languages.
    I keep a set of files I'm working on on a usb stick (which appears to be working perfectly).
    Sometimes, but not always, when I open up a one of those files on the key, it shows up as square-box gibberish in the sql worksheet window.
    I can open the same file with notepad just fine, and paste the contents into the same sql worksheet just fine.
    But it's a darned nuisance, not to mention an opportunity to overwrite my work if I forget to close the open file in notepad and save it later.

    I've had a few moments to try to track down more info on this problem.
    I work on a 64bit vista machine at work and a 32bit windows xp machine at home.
    I'm at home, so I'll post what I discovered here, and then post what happens on the 64bit when I get to work tomorrow.
    All the files I'm discussing have only the standard ascii characters in them.
    Both machines have the same fonts and font setup, and the same OS language. I do not believe this is a font or language issue.
    I believe it may be an encoding issue.
    I opened up a .txt file with sql developer. It happened to work fine this time.
    I opened up the same .txt file with notepad, and saved it to a new .sql extension. It opened fine with sql developer.
    I opened up the original .txt file with notepad and saved it to a new .txt filename and chose the unicode encoding instead of the ansi encoding that notepad was defaulting to. I also used notepad to save the file to another .txt file and chose a utf-8 encoding for it.
    I opened up the unicode encoding file using sql developer and got gibberish. Upon closer inspection, I could actually read the code in the file, but each character had a box between it. I'll use [] to represent a box. So, my first line looked like this: [] [] []b[]e[]g[]i[]n[].
    I opened up the utf encoding file using sql developer and got some gibberish, but most of the file looked fine.
    My environment setting had UTF-8 as a setting.
    I changed the environment setting to UTF_16, and re-opened the files.
    The file saved as unicode is now readable and the other files are now complete gibberish.
    I'm guessing that my work machine has a different default encoding scheme at the operating system level, because I believe both are set up with the same settings inside sql developer. (I used the same written instructions for both.)
    I'll post what I find at work tomorrow.
    If this turns out to be correct, it would be nice if sql developer automatically checked the encoding of the file when it was loaded and acted accordingly. That appears to be a possible course of action, because when I open up each of the encoded files in notepad, it (a) displays each of them correctly automatically and (b) when I do a save as, it shows the encoding the file was last saved in as the default value.

Maybe you are looking for

  • Sorting in oracle

    hi! how do we do sorting in oracle? can you please explain me with an example. thanks in edvance. regards prasad

  • Need help with a magic square program

    Hi, I have to write a code that prints out first 10 magic square numbers -- magic square numbers: numbers that is a perfect square and sum of consecutive integers (like 36 -- 6 squared or sum of 1 to 8) here's my code: public class Loop { public stat

  • Install on a Mac Pro G5

    I have a mac pro G5 with a 1.8GHz Dual Processor. Can I install a copy of Leopard (v10.5.7) on it, or do I need an Intel?

  • Trend Micro Internet Security 2009

    Does anyone know how I can fix the settings on Trend Micro Internet Security 2009, so that I am able to download songs again? The song partially downloads, and then it says processing file, and never finishes. What can I do to fix this?

  • HT1414 iPod doesn't restore!! HELP!!!!

    Hello, I have an iPod 2nd or 3rd Gen, and I need to restore it, but it is locked with a password, and it hasn't been synced to my iTunes account, I'm not sure how to fix this, please help! I keepy trying to reset it, but nothing is working! I can't s