Opening a text file in notepad using swing

Hi,
I am trying to getting all files and directoriess from my Home Drive to JTreeModel, and i also want whenever i click into text file the contents should be open in notepad, but i am not able to add this feature, can any one help?
Suresh

Suresh_Dewangan_1981 wrote:
No, I am using java 1.5 only, please help me accordingly.
import java.io.IOException;
class StartTxt {
    public static void main(String args[])
        throws IOException
        String fileName = "c:\\temp\\test2.txt";
        String[] commands = {"cmd", "/c", "start", "\"DummyTitle\"",fileName};
        Runtime.getRuntime().exec(commands);
}Bye
RG.

Similar Messages

  • Problem with opening various text files in notepad through java

    Hi friends,
    I need to open any .txt file in notepad by running the code in Java.I could open the notepad through java but not a perticular file.I dont even want to hard code my program that only one perticular file will open through it.I want it generalised...if anyone could help me,it would be really nice...
    thanks
    Vishal.

    If your program opens notepad I'll delete it because I set UltraEdit as my default editor. So if you already must use system-specific code, how about grabbing a Windows manual to find out how to use the editor registered for these files? (Hint "start").

  • How do I open a text file to sort using bubble sort?

    Hi,
    I have a text file, which is a list of #'s.. ex)
    0.001121
    0.313313
    0.001334
    how do you open a text file and read a list? I have the bubble sort code which sorts.. thanks

    I wrote this, but am getting a couple errors:
    import java.util.*;
    import java.io.*;
    public class sort
         public static void main(String[] args)
              String fileName = "numsRandom1024.txt";
              Scanner fromFile = null;
              int index = 0;
              double[] a = new double[1024];Don't use double. You should use something that implements Comparable, like java.lang.Double.
              try
                   fromFile = new Scanner(new File(fileName));
              catch (FileNotFoundException e)
    System.out.println("Error opening the file " +
    " + fileName);
                   System.exit(0);
              while (fromFile.hasNextLine())
                   String line = fromFile.nextLine();
                   a[index] = Double.parseDouble(line);Don't parse to a double, create a java.lang.Double instead.
                   System.out.println(a[index]);
                   index++;
              fromFile.close();
              bubbleSort( a, 0, a.length-1 );No. Don't use a.length-1: from index to a.length-1 all values will be null (if you use Double's). Call it like this:bubbleSort(a, 0, index);
    public static <T extends Comparable<? super T>> void
    d bubbleSort( T[] a, int first, int last )
              for(int counter = 0 ; counter < 1024 ; counter++)
    for(int counter2 = 1 ; counter2 < (1024-counter) ;
    ) ; counter2++)Don't let those counter loop to 1024. The max should be last .
                        if(a[counter2-1] > a[counter2])No. Use the compareTo(...) method:if(a[counter2-1].compareTo(a[counter2]) > 0) {
                             double temp = a[counter2];No, your array contains Comparable's of type T, use that type then:T temp = a[counter2];
    // ...Good luck.

  • How to open a text-file with notepad from labview-vi?

    Hello,
    how can i execute a program from a vi?
    I want to open a textfile with Windows7-Notepad after selelecting it from a file-path-control and pressing an open-button.
    Thx for help
    Solved!
    Go to Solution.

    Use the command line.  Something like cmd /c notepad c:\temp\blah.txt should work.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to open a text file using button click event

    hi, How can i open a text file in a textpad or notepad on the click event of a button.?
    Thanks
    Jay

    Pnt,
    this will not work LV 8.0.1 and LV 8.6 will give back error 193.
    Attached is a VI to use the ShellExecute WinAPI. The VI is LV 7.1.1.
    Message Edited by waldemar.hersacher on 10-09-2008 10:48 PM
    Waldemar
    Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
    Don't forget to give Kudos to good answers and/or questions
    Attachments:
    ShellExecute.zip ‏27 KB

  • Can Quickword open a text file 10K?

    I have a couple of simple, notepad text files.
    6K opens (after about 5 seconds)
    90K, well, it doesn't
    480K, neither does this.
    I can open the files using notepad, direct from the phone.
    Can anyone else open simple text files of this range of size.
    ...Lyall

    Well, I have a Tab Separated variable file (output from Excel) with about 20 columns.
    I edited it down from 5000 lines to 1000, 500 and 250 lines.
    I then copied all 4 files to the E90.
    QuickWord will open the 250 line file after about 5-10 seconds.
    It does NOT open (at least within my lifetime) the 500+ line files.
    So, how do I look at text files on the E90?
    ...Lyall

  • Opening a text file in server from an applet running in the client

    Friends,
    I want to open a text file in the server(The server machine uses tomcat 4.1.12 server)from an applet running in the client machine;
    The applet invokes a servlet that opens the text file;this text file is opened in the server machine; but I want it to be opened in the client machine where the applet is running.
    Plese help me to get around this.

    You can open the textfile on the servlet and then send the information to the client (applet) as stirngs. The must then applet convert the stirngs into some object or simply display the information in someway. But then the text file that you are opening must be stored in some relevant tomcat directory e.g. on the server. If you want to open a file on the clients computer, you get into signed applets.

  • Setting Font for converting multiple text files into PDF using VB 6.0

    Dear All,
    Am converting multiple text files into PDF using VB6.0. Currently, am unable to control the font face and size for the generated files. Below is the procedure am using for each file;
    Public Sub proc_convert_to_PDF(srcFilename As String, destFilename As String)
    Dim p_AcroApp As CAcroApp
    Dim p_VDoc As CAcroAVDoc
    Dim p_DDoc As CAcroPDDoc
    Dim IsOk As Boolean
    Set p_AcroApp = CreateObject("AcroExch.App")
    Set p_VDoc = CreateObject("AcroExch.AVDoc")
    Call p_VDoc.Open(srcFilename, "")
    Set p_VDoc = p_AcroApp.GetActiveDoc
    If p_VDoc.IsValid Then
    Set p_DDoc = p_VDoc.GetPDDoc
    ' Fill in pdf properties.
    p_DDoc.SetInfo "Title", Format(Date, "dd-mm-yyy")
    p_DDoc.SetInfo "Subject", srcFilename
    If p_DDoc.Save(1 Or 4 Or 32, destFilename) <> True Then
    MsgBox "Failed to save " & srcFilename
    End If
    p_DDoc.Close
    End If
    'Close the PDF
    p_VDoc.Close True
    p_AcroApp.Exit
    'Clear Variables
    Set p_DDoc = Nothing
    Set p_VDoc = Nothing
    Set p_AcroApp = Nothing
    End Sub
    What I need;
    1) to be able to set the font face of the destination file ( destFilename)
    2) to be able to set the font size of the destination file ( destFilename)
    Am using Adobe Acrobat 7.0 Type Library
    Kindly Help.
    Thanks in advance

    We didn't say it doesn't work. We said it isn't supported.
    There are a number of other ways to make a PDF. The one which would
    give the most control is if your application directly printed to GDI,
    controlling the font directly. This could print to Adobe PDF.
    You could look for an application that gives control of font for
    printing.
    You could use a text-to-PostScript system and distill the result. You
    could even look for a non-Adobe text-to-PDF.
    Working in the unsupported and dangerous world you chose, the font
    size for text conversion is set (and this is very bad design from
    Adobe) in the settings for Create PDF > From Web Page. There is no API
    to this.
    Aandi Inston

  • Recommended way to open a text file included in a jar?

    Forgive me if this seems like an ignorant question, but I keep reading two different things about loading resources in the javadocs and forums, and can't seem to connect them...
    Say you want to open a text file and read the contents into a String or a List. Apparently, the preferred way to do this is something like:
    fileName = "myFile.txt";
    BufferedReader br = new BufferedReader(new FileReader(new File(fileName)));
    String line;
    while ((line = reader.readLine()) != null) {...}
    Now say you want to distribute your app in a jar file, with the text file included in the jar file. The above method won't work, because a FileReader operates on a File, and as I understand it, once myFile.txt is packed into the jar file, it's no longer a "file".
    So what do you do? I keep reading that the best way to open the jarred text file is to use something like this:
    InputStream is = getClass().getResourceAsStream(fileName);
    Here's where I get confused: InputStream, and all of its subclasses, are now supposedly dispreferred for reading character data (in preference to Reader, as above). But no subclass of Reader can wrap around an InputStream, which would facilitate the reading of character data greatly, with methods like readLine().
    So my question is: What's the best way to read a text file from within a .jar?
    Thanks,
    Gregory

    great! glad it's working
    here is a statement from the javadoc
    http://java.sun.com/j2se/1.4.2/docs/api/java/io/InputStreamReader.html
    For top efficiency, consider wrapping an InputStreamReader within a BufferedReader. For example:
    BufferedReader in
    = new BufferedReader(new InputStreamReader(System.in));
    kind regards
    Waken16

  • Opening a text file in a bundle with C++

    Hi folks! I'm working with bundles for the first time, and I'd like to know how to open a text file inside one with C++. What I have now is this:
    ifstream file = new ifstream(fileName.c_str());
    if (!file->is_open())
    return false;
    Where fileName is a std::string. This is the way I'm accustomed to opening files (I'm from a Windows development background -- don't hate me! ). Unfortunately, the is_open() test always fails.
    I know how to get the path of the bundle. Once I add on my data subdirectory and file name, the fileName variable ends up as this:
    /Users/sb/...project location.../Debug/MyProg.app/data/Dev Options.ini
    Should the path be different somehow? Thanks for any help!

    Your data folder most likely isn't directly inside the .app bundle. The first directory inside an .app bundle is named Contents. The article at the following URL should help you:
    http://www.meandmark.com/bundlespart1.html
    If you're going to use C++ streams to open files, you'll want to ignore the section on opening the file in Part 3 of the article. You'll want to read up on the Core Foundation CFURL functions. You'll want to use one of the functions that gives you a path to the text file that you can pass to a C++ file stream.

  • Open a PDF file in linux using java

    Hi..
    How can I open a PDF file in linux using java.
    I am able to open PDF in windows and mac using this code
    in Windows
    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + path_of_PDF);
    in mac
    Runtime.getRuntime().exec("open " + path_of_PDF);
    But nothing is working with linux.
    Please help
    Thanks

    One thread is enough:
    http://forum.java.sun.com/thread.jspa?threadID=5267458

  • Opening a Text File?

    I am having no luck opening a text file that contains comma delimited data. I have tried some different ways and am having no luck at all. I can't even get a open file dialog to appear when I click a button.
    I did not see any example of this in the sdk sample plugins.
    Anyone able to help me out.
    The file I am trying to load is "D:\Test\TestFile.txt".

    If you did not escape the path's backslashes that may be part of the problem.
    Some example code:
    local LrDialogs = import 'LrDialogs'
    local LrFileUtils = import 'LrFileUtils'
    local LrPathUtils = import 'LrPathUtils'
    local file = 'C:\\temp\\Testfile1.txt'
    if not LrFileUtils.isReadable(file) then
    local dialogresult = LrDialogs.runOpenPanel {
      title = 'Select input text file',
      allowsMultipleSelection = false,
      initialDirectory = LrPathUtils.parent(file)
    file = dialogresult and dialogresult[1] or nil
    end
    if file and LrFileUtils.isReadable(file) then
    local collectedLines = {}
    for line in io.lines(file) do table.insert(collectedLines, line) end
    LrDialogs.message(table.concat(collectedLines, '\n'))
    end
    Herb

  • How to open a text file

    hello
    if so have an idea on how to open a text file
    thanks

    File file=new File("[path to the text file]");
    String encoding="[encoding of the file]";
    BufferedReader reader=new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding));
    // Do whatever you like with the reader
    // For example write the text file to the output
    String line;
    while ((line=reader.readLine())!=null)
    System.out.println(line);
    reader.close();Hope it helps,
    Marcin
    PS. This is not the write forum category to post this question.

  • I cannot open any pdf files! I used to be able to. Have a mac.

    I cannot open any pdf files. I used to be able to. If I open them I get a blank screen. Have a mac. Help!!!!!

    Hi Charlie,
    First, thanks for responding. These are mostly emails with attachments or documents that I have. I download them and once I open them the page is blank. I also cannot look at them in Preview. The same problem. I called Apple and they said they assume I have an older software version. They are going to send new software. I am not really sure this will solve my problem. If you have any suggestions, please let me know. Thanks!

  • Can Muse open existing text files authored in GoLive?

    Can Muse open existing text files authored in GoLive and or Dreamweaver?

    Unfortunately not, for now, Muse can only open .muse extension files, created within Muse.

Maybe you are looking for

  • Webi report using openDocument URL,the window does not close..

    Hello, While viewing a Web intelligence report using openDocument URL, the window does not close after clicking on Document -> Close option, and the report remains open. And if I close the browser, the session of the user in InfoVierw remains opened

  • Non-configurable materials with EK02 costing

    Hi all, We have a range of non configurable manufactured materials which, when used in standard sales orders, generate a production order and BOM. Presently the cost is automatically generated from the material master and is populated as a VPRS cost.

  • Making a map-style blowup section?

    Hello! I'm fairly new to Illustrator; I've been playing with it for a few days and I'm getting the hang of it, but I can't seem to figure one particular thing out.  I'm working on a vector map and I'd like to be able to take a section of it and blow

  • Highlighti​ng different plots

    I have an application where I generate10-20 different plots on one graph.  I know how to use the legend, but it's still tough to see which plot goes with which data set.  Is there a way have the individual plot names show up when I mouse over a plot?

  • Zebra programming language

    insted of writng the zebra programming language, any other way to convert the smart form in to zebra programing language?