How to make an applet to read the Text file present inside a jar

Hi All,
I have writen one applet named ReadFile.java which reads a text file present in the same directory and does some manipulation of text file contents.
The applet code runs successfully when i run the applet in command prompt like
{color:#ff0000}*java ReadFile*{color}
And i am getting the needed results.
Then i made a jar file with the applet code and text file as
{color:#ff0000}*jar cvf rf.jar ReadFile.class File1.txt*{color}
Then i have inlcuded this applet inside a html file as
{color:#ff0000}*<applet code= "ReadFile.class" width= "500" height= "300" archive = "rf.jar" ></applet>*{color}
after this when i load the html file, the applet code is not executed fully. Its throwing FileNotFoundException: File1.txt.
Applet is not recognizing trhe text file present inside the jar file.
Can any body explain me how to overcome this problem. Any setting needs to be done for making the applet indicate the presence of Text file inside the jar file.

what code in your applet gets the text file and reads it? are you using getResource or something similar?

Similar Messages

  • How to make SSIS packages automatically read the input file from a path?

    Currently I am using a SSIS package to read data from a .dat file and load it into SQL Server tables.
    I am placing the input .dat file on the desktop. In the connection manager -> Browse option, I am pointing this file to create connection.
    The file naming convention is like - aSNAP_Data_20140926_P-2014-09-26_07.02.36
    However, I need the SSIS package to automatically read the input file from a folder which is located in a remote server. This folder has lots of files where input files are added on a daily basis with the date value in the file name as mentioned above.
    I want to schedule the SSIS package to run daily and take the latest file in the folder based on the date.
    Please let me know how to do it. Any help would be highly appreciated.....
    Thanks in advance.

    Hi SQL_SSIS_Dev,
    According to your description, you want to get the latest file from a path to a SQL Server table. After testing the issue in my environment, we can refer to the following steps to achieve your requirement:
    Create two variables, VarFolderPath stores the folder path in which our files exist, VarFileName hold the value of most recent File Name.
    Drag a Script Task from SSIS Toolbox to Control Flow Pane, then select “User::VarFolderPath” as ReadOnlyVariables, select “User::VarFileName” as ReadWriteVariables.
    Then Edit Script with the C# code below:
    Add “using System.IO;” into namespace.
    Add the code below under Main function:
    var directory= new DirectoryInfo(Dts.Variables["User::VarFolderPath"].Value.ToString());
                FileInfo[] files = directory.GetFiles();
                DateTime lastModified = DateTime.MinValue;
                foreach (FileInfo file in files)
                    if (file.LastWriteTime > lastModified)
                        lastModified = file.LastWriteTime;
                        Dts.Variables["User::VarFileName"].Value = file.ToString();
    Drag a Data Flow Task to Control Flow Pane and connect to Script Task.
    In the Data Flow Task, drag a Flat File Source with a file in the source folder as all the files have same structure as the File name.
    Add the property below the Flat File Connection Manger expression:
    Property: ConnectionString      Expression: @[User::VarFolderPath] +"\\"+ @[User::VarFileName]
    Drag an OLE DB Destination that connect to the Flat File Source, then configure a table to store the data.
    The following screenshot is for your reference:
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How to read the text file present in the Al11 server through our program?

    My requirement is that , i have one file already present in the AL11 server. Now i want to take this file so that I can read this file .
    So will you please help me , how to read the file from AL11 server in our program ?
    Thankx in advance

    Hi..
    I too agree to the above post .. SEARCH in SCN before posting..
      DATA: lv_filename  TYPE string, "File name
            lv_line      TYPE string. "One line entry in a file
      lv_filename = iv_file_name.
      IF iv_location = gc_application.
        IF iv_record_count IS SUPPLIED.
      Open file
          IF gv_file IS INITIAL.
            OPEN DATASET lv_filename FOR INPUT IN TEXT MODE
                                     ENCODING DEFAULT.
                                     ENCODING DEFAULT
                                     IGNORING CONVERSION ERRORS.
            IF sy-subrc <> 0.
              RAISE file_open_error.
            ENDIF.
            gv_file = gc_check.
          ENDIF.
      Read data
          DO iv_record_count TIMES.
            READ DATASET lv_filename INTO lv_line.
            IF sy-subrc <> 0.
      Close file
              CLOSE DATASET lv_filename.
              IF sy-subrc NE 0.
                RAISE file_close_error.
              ENDIF.
              CLEAR gv_file.
    Exit from the loop
              EXIT.
            ENDIF.
    Regards
    Ansari

  • IOS 7 back ground makes it difficult to read the text.  How can I change it in mail and messages?

    HI,
    iOS 7 back ground makes it difficult to read the text.  I know I can't change it in mail and messages, but Apple really needs to allow some customization.  This is really difficult to read for older eyes.

    yeah I agree with all you guys statements, the color scheme on IOS 7 *****,
    I am having to constantly turn on off on off on off  "invert color" mode just to switch between
    the home screen, typing, and reading text messages, its an absolute pain!!
    I never had any of this trouble in IOS 6.
    What they SHOULD do, is make 2 different color schemes
    one LIGHT color scheme,
    and one DARK color scheme, for those using "invert colors" frequently.
    See, what Apple doesn't seem to understand is, when you turn on "invert colors",
    the lock screen turns bright WHITE, so you have to turn invert colors OFF just to read the lock screen,
    then back ON when you want to type an email, read a text message, etc etc, then turn it off again when
    you want to play a game.
    and see, after awhile, when you switch invert colors on off on off after so  many times, it drains on the devices resources, & you have to reboot the device to get accessibility options working again.   I have to reboot the device several times a day now just because of that, when its just a simple fix of adding a darker color scheme as a 2nd or alternative option. 
    I mean, even as a normal sighted person, turning on invert colors is annoying when your at the lock screen or playing a game, think about those of us who depend upon it just to read text on the screen..  VoiceOver has the smilar issues when you have to turn it off on off on all the time it drains the system resources of the phone also,
    so I agree completely...
    but ya know, they don't listen to us...  cuz its an option they don't use, so they don't understand... If they used that option for even 5 seconds, they'd understand what we're talking about....  What Apple should do is hire one of us as a beta tester to help them test out these types of issues,  from one of us like myself who knows a thinkg or two about accessibility options of the phone.
    I've been an Apple idevice fan for years, but, IOS 7 was a major disappointment in the accessibility arena..
    kind regards,
    Tom

  • Powershell script - how to read a registry hive and store the value in text file and then again read the text file to write the values back in registry

    Hi All,
    powershell script Method required to read a value from registry and then taking the backup of that values in some text file.
    For example the hive is
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path
    and under path i need to take back up  of values in some text file and then put some value in the registry after back is taken in text file.
    Also how to read the text file values so that we can again write to registry hive  back from the back up text file.
    Your help is much appreciated.
    Umeed4u

    I think you need to read this first:
    http://social.technet.microsoft.com/Forums/scriptcenter/en-US/a0def745-4831-4de0-a040-63b63e7be7ae/posting-guidelines?forum=ITCG
    Don't retire TechNet! -
    (Don't give up yet - 12,830+ strong and growing)

  • How to Read the "text file and csv file" through powershell Scripts

    Hi All
    i need to add a multiple users in a particular Group through powershell Script how to read the text and CSV files in powershell
    am completly new to Powershell scripts any one pls respond ASAP.with step by step process pls
    Regards:
    Rajeshreddy.k

    Hi Rajeshreddy.k,
    To add multiple users to one group, I wouldn't use a .csv file since the only value you need from a list is the users to be added.
    To start create a list of users that should be added to the group, import this list in a variable called $users, the group distinguishedName in a variable called $Group and simply call the ActiveDirectory cmdlet Add-GroupMember.
    $Users = Get-Content -Path 'C:\ListOfUsernames.txt'
    $Group = 'CN=MyGroup,OU=MyOrg,DC=domain,DC=lcl'
    Add-ADGroupMember -Identity $Group -Members $Users

  • How can i read the text files and buffer the data in Vector?

    hi. I have been running into this problem for days, but with no luck and losing right direction.
    The problem is : I am trying to read a text file and buffer the data into a
    Queue for each user.
    the sample text file is as below:( 1st column is timestamp, 2nd is user_id, 3rd is packet_id, 4th is packet_seqno, 5th is packet_size)
    0 1 1 1 512
    1 2 1 2 512
    2 3 1 3 512
    3 4 1 4 512
    4 5 1 5 512
    5 6 1 6 512
    6 7 1 7 512
    7 8 1 8 512
    8 9 1 9 512
    9 10 1 10 512
    10 1 2 11 512
    11 2 2 12 512
    12 3 2 13 512
    13 4 2 14 512
    14 5 2 15 512
    15 6 2 16 512
    16 7 2 17 512
    17 8 2 18 512
    18 9 2 19 512
    19 10 2 20 512
    20 1 3 21 512
    21 2 3 22 512
    22 3 3 23 512
    23 4 3 24 512
    24 5 3 25 512
    25 6 3 26 512
    26 7 3 27 512
    27 8 3 28 512
    28 9 3 29 512
    29 10 3 30 512
    30 1 4 31 512
    31 2 4 32 512
    32 3 4 33 512
    33 4 4 34 512
    34 5 4 35 512
    35 6 4 36 512
    36 7 4 37 512
    37 8 4 38 512
    38 9 4 39 512
    39 10 4 40 512
    40 1 5 41 512
    41 2 5 42 512
    42 3 5 43 512
    43 4 5 44 512
    44 5 5 45 512
    45 6 5 46 512
    46 7 5 47 512
    47 8 5 48 512
    48 9 5 49 512
    49 10 5 50 512
    50 1 6 51 512
    51 2 6 52 512
    52 3 6 53 512
    53 4 6 54 512
    54 5 6 55 512
    55 6 6 56 512
    56 7 6 57 512
    57 8 6 58 512
    58 9 6 59 512
    59 10 6 60 512
    60 1 7 61 512
    61 2 7 62 512
    62 3 7 63 512
    63 4 7 64 512
    64 5 7 65 512
    65 6 7 66 512
    66 7 7 67 512
    67 8 7 68 512
    68 9 7 69 512
    69 10 7 70 512
    70 1 8 71 512
    71 2 8 72 512
    What I wanna do is to read all the data above and buffer them in a queue for each user( there are only 10 users in total).
    I already created a class called Class packet:
    public class packet {
        private int timestamp;
        private int user_id;
        private int packet_id;
        private int packet_seqno;
        private int packet_size;
        /** Creates a new instance of packet */
        public packet(int timestamp,int user_id, int packet_id,int packet_seqno, int packet_size)
            this.timestamp = timestamp;
            this.user_id=user_id;
            this.packet_id=packet_id;
            this.packet_seqno=packet_seqno;
            this.packet_size=packet_size;
    }then I wanna to create another Class called Class user which I can create a queue for each user (10 users in total) to store type packet information. the queue for each user will be in the order by timestamp.
    any idea and sample code will be appreciated.

    Doesn't sound too hard to me. Your class User (the convention says to capitalize class names) will have an ArrayList or Vector in it to represent the queue, and a method to store a Packet object into the List. An array or ArrayList or Vector will hold the 10 user objects. You will find the right user object from packet.user_id and call the method.
    Please try to write some code yourself. You won't learn anything from having someone else write it for you. Look at sample code using ArrayList and Vector, there's plenty out there. Post in the forum again if your code turns out not to behave.

  • Trying to read the text file via Flex FileStream.

    Hello,
    I am following the Flex Help and trying to read a text file.
    I have created project called test, and within test.mxml, I have
    created the <mx:script> tags and within I am pasting this
    code yet I get errors:
    What am I doing wrong? Please help.
    Please see the code:

    You cannot do all that complex assignment work outside of a
    function. Because of the way components are generated/compiled, the
    declared vars do not exist when called.
    Declare the vars in instance scope, but use an init()
    function to do the assignments.

  • DLL is failing to read the text file on RTOS

    I have created a DLL using Fortran Microsoft Power STation 4.0.  The DLL reads data from text files.  A vi is created to call this dll.  This vi is working fine in winodows.  It is reading from the text files and manipulates.
    When this vi is donwloaded to RTOS Labview 7.1, it fails to read the file and the RT reboots.  The error message is "file not found (filename)".  The file is present is the current directory of DLL.
    Please assist me in solving this problem.  My email Id is: [email protected] or [email protected]

    Hello GTRE,
    It seems like something isn't letting you access that DLL.  Do you have the DLL moved onto the RT target?  What is your real-time target?  Does the DLL require access to other resources?  What specifically does the error message say?  Does it contain an error code?
    Answering these questions will allow us to narrow down the problem - thanks!
    Janell R | Applications Engineer

  • Reading a text-file from within a Jar-file...

    I've made a program, that reads from a text-file. And it works great. But when I try to put the program into a jarfile, I get a fileNotFoundException... I have the textfile both inside and outside the jarfile... with the same result.
    Does anyone know what I might be doing wrong?
    Thanx in advance!
    Martin

    Depends on the path you enter for the text file. If you simply put "filename.txt" then you should try to have the file in the same directory as the class which accesses the file.
    Cheers,
    H�vard

  • Reading a text file in archive in jar

    Hi,
    I am unable to read a text file in my jar archive.
    Example code:
    try
    InputConnection con =
    (InputConnection) Connector.open("file://text/info.txt", Connector.READ);
    InputStream in = con.openInputStream();
    StringBuffer buf = new StringBuffer();
    int ch;
    while((ch = in.read()) != -1 )
    buf.append((char) ch);
    in.close();
    form.append(buf.toString());
    } catch (Exception e) { e.printStackTrace(); }
    Any ideas how I can do that?
    Thanks.

    You have to use java.lang.Class`s getResourceAsStream method. Your code:
    try
    StringBuffer buf;
    Class mc = buf.getClass();
    InputStream in = mc.getResourceAsStream("/text/info.txt");
    buf = new StringBuffer();
    int ch;
    while((ch = in.read()) != -1 )
    buf.append((char) ch);
    in.close();
    form.append(buf.toString());
    } catch (Exception e) { e.printStackTrace(); }

  • WebLogic writes to a text file and an applet reads the text file

    Hi there,
    I need some help here!
    I have an applet that needs to read from a text file:
    final URL prtDataURL = new URL("http://" + getCodeBase().getHost() + ":" + getCodeBase().getPort() + "/ESTC/lib/prtDataFile.txt");
                final URLConnection urlConn = prtDataURL.openConnection();
                urlConn.setUseCaches(false);
                urlConn.setDoInput(true);
                urlConn.setDoOutput(false);
                final InputStreamReader is = new InputStreamReader(urlConn.getInputStream());
                final BufferedReader in = new BufferedReader(is);
                String inputLine;
                while ((inputLine = in.readLine()) != null){
                    String[] tmp = inputLine.split("§");
                    this.dateTime = tmp[0];
                    this.quanTot = Integer.parseInt(tmp[1]);
                    this.quanSco = Integer.parseInt(tmp[2]);
                    this.quanSef = Integer.parseInt(tmp[3]);
                    this.valTot = Double.parseDouble(tmp[4]);
                    this.valSco = Double.parseDouble(tmp[5]);
                    this.valSef = Double.parseDouble(tmp[6]);
                in.close();
                is.close();and this is ok.
    Now I have the web server (WebLogic) that must write, at regular time intervals, to that file (prtDataFile.txt). The web application writes to the file (which belongs to the application).
    I've tried open the file with the File object but since the war file is unexploded I can't get the real path!
    I've tried open an url connection,
    final URL url = new URL("http://10.191.33.249:16801/ESTC/lib/prtDataFile.txt");
    final URLConnection connection = url.openConnection();
    connection.setDoOutput(true);
    connection.setUseCaches(false);
    connection.setDoInput(false);
    OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());
    out.write(currentDate + "§" + quantTot + "§" + quantSco + "§" + quantSef + "§" + valTot + "§" + valSco + "§" + valSef);;
    out.flush();
    out.close();which seems a little stupid since I'm opening an URLConnection to the same place where the application is. Anyway it doesn't work, i.e., it doesn't write to the file but it doesn't gives me any errors or exceptions.
    Is there another way to get this two pieces communicating?
    Thanks in advance

    I have almost the exact same problem, and I am in the same situation as you are with respects to the language.
    I am simply trying to create a file and output some garbage to it but my applet always spits back a security violation. I've tried eliminating the restrictions on the applet runner I use but I still get the error.
    My method:
    debug = new Label() ;
    debug.setLocation( 20, 20 ) ;
    debug.setSize( 500, 15 ) ;
    add( debug ) ;
    // output
    try
         OutputStream file = new FileOutputStream( new File( "" + getCodeBase() + "output.txt" ) ) ;
         byte[] buffer = { 1, 2, 3, 4, 5 } ;
         file.write( buffer ) ;
         file.close() ;
    } catch( Exception e )
         debug.setText( e.toString() ) ;
         Can anyone tell why this isnt working?

  • How do I read a text file in a Jar Executable?

    Hello All,
    I have a need to package a text file into a Jar Exectable file and then have my java code read that text file in using a BufferedReader. Can anyone out there tell me how to do this? My first question is how do I reference this file by the path name? O, I'm also using Windows.
    Thanks for your help.
    Karl

    I have the same problem with kportner . I did by joop_eggen but I got the error at:
    BufferedReader in = new InputStreamReader(is);Can't conver from BufferedReader to InputStreamReader
    When I up my applet to server and get it from client. My applet couldn't read the text file.
    Any one help me!
    Thanks.

  • Read a text file before knowing the encoding

    Hi,
    I've wrote a AppleScript to adjust time delay of *.lrc file(txt file but different extension).I only got a messed up text, in other aspect, it works well. I understand applescript read the text file using the wrong encoding, but I can't just set the encoding to UTF-8, for it can be UTF-8 and it can be Shift-JIS, Big5 andGB18030 as well. I don't know how to open text without getting messed up and write the result to a new text file on desktop using UTF-8 encoding. Can anyone help me with this? Thanks in advance.
    Code:
    on run
      set _lrcFile to (choose file)'s POSIX path
      display dialog "Time to delay (sec):" with title "Adjust LRC Delay" default answer "-0.5"
      set _timeDelay to text returned of result
      try
      set _timeDelay to _timeDelay as real
      on error
      display dialog "Input must be a real" with title "Error" buttons {"Stop"} default button "Stop"
      error number -128
      end try
      set _paraList to paragraphs of (read POSIX file _lrcFile)-->I don't know how to read text file properly here.
      set _newLrc to ""
      repeat with _para in _paraList
      set _timecode to do shell script "sed 's/\\[\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}.[0-9]\\{2\\}\\)\\]\\(.*\\)/\\1 \\2/'<<<" & quoted form of _para
      if _timecode as string is not (contents of _para) then
      set _timecode to words of _timecode
      set _min to (item 1 of _timecode) as integer
      set _sec to (item 2 of _timecode) as real
      set _sec to _sec + _timeDelay
      set _min to _min + _sec div 60
      set _sec to _sec mod 60
      set _sec to (round (_sec * 100)) / 100
      if _min < 10 then
      set _min to "0" & _min as string
      else
      set _min to _min as string
      end if
      if _sec < 0 then
      set _sec to "00.00"
      else if _sec < 10 then
      set _sec to "0" & _sec as string
      else
      set _sec to _sec as string
      end if
      if (count of _sec) < 5 then
      set _sec to _sec & "0"
      end if
      set _lyrics to do shell script "sed 's/\\[\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}.[0-9]\\{2\\}\\)\\]\\(.*\\)/\\3/'<<<" & quoted form of _para
      set _newLrc to _newLrc & "[" & _min & ":" & _sec & "]" & _lyrics & return
      else
      set _newLrc to _newLrc & contents of _para & return
      end if
      end repeat
      -->write _newLrc to destop here (using UTF-8 encoding)
    end run
    Sample of *.lrc and the result after delaying 0.5s.

    Hope this post will help people doing their homeworks...
              StringBuffer tmpBuffer = new StringBuffer();
              try {
                   URL url = new URL("http://.../test.txt");
                   URLConnection urlconnection = url.openConnection();
                   long l = urlconnection.getContentLength();
                   tmpBuffer.append("Content Length = " + l);
                   BufferedReader in =
                        new BufferedReader(new InputStreamReader(url.openStream()));
                   String line;
                   while ((line = in.readLine()) != null) {
                        tmpBuffer.append("\n" + line);
                   in.close();
              } catch (Exception e) {
                   //System.out.println(e.toString());
              if (tmpBuffer != null) {
                   wdContext.currentContextElement().setZoneMessage(
                        tmpBuffer.toString());

  • Do any of you have trouble reading the text on the 15" MBP?

    Does the 1440x900 resolution make it difficult to read the text on the screen?

    Not for me, but my eyes are good at close range for someone in his 60s. Those who are more farsighted and need reading glasses for close work may have more trouble.
    The things to be concerned about are the menus, dialog boxes, and other Finder and OS elements that can't be enlarged except by reducing the display resolution, which blurs everything on the display. In most applications' windows, you can easily change the font size or zoom in on the page as a whole to suit yourself. Ultimately, whether you're comfortable with the screen resolution at its native (maximum) setting is a purely personal decision that only you can make. I strongly advise you NOT to buy any computer whose display is uncomfortable to use at its native setting, because you will be looking at a blurry screen ALL the time if you have to use any LCD display at a non-native resolution.

Maybe you are looking for

  • Upgrade to 7.1 and Quicktime will not open

    I upgraded to QT 7.1 when I got an ipod this week and now I cannot open quicktime at all. I cannot put movies on my ipod due to this. the message I get when I open QT is: "Buffer overrn dectected! Program: C:\programfiles\quicktime\quicktimeplayer.ex

  • Error in http-jdbc

    with reference to blog /people/bhavesh.kantilal/blog/2006/07/03/jdbc-receiver-adapter--synchronous-select-150-step-by-step i completed http to jdbc scenerio but in moni i got this error com.sap.aii.af.ra.ms.api.DeliveryException: Error processing req

  • Can we call LabVIEW VI's (saved at shared location say server)from two different test stations?

    Hello All, My question is related to calling and execution of LabVIEW Vis  from two or more different teststation(Test System) using NI TestStand. Following are some definitions to understand the question better A Test Station:is a independent sytem.

  • Firefox downloads a file, even if I choose "Cancel".

    If I click a link to a file (eg, PDF, DOC), a dialog box appears that asks me to either "Open with [some application]" or "Save File". This dialog has a "Cancel" or "OK" button. So if I choose cancel -- meaning that I do not want to download the file

  • Problems deleting data i got ORA-01562 and ORA-01650 errors

    Hi, I got this to errors: ORA-01562: failed to extend rollback segment number 14 ORA-01650: unable to extend rollback segment RB3 by 128 in tablespace ROLLBACKWhen i been trying to delete some information of one table, this table has approximately 10