How to write multiline String in a JLabel

How can i write a string that is shown in many lines in a JLabel. Or is there any orher way to write them?
Also, similarly how to write tooltip text that spans across many lines. Not just one line

import java.awt.*;
import javax.swing.*;
public class UseThisTheNextTimeYouFeelLikePostingEelops {
    public static void main(String[] args) {
        String str = "This is \nmy example \nof a multi-line \nJLabel";
        JLabel strLabel = new JLabel (str);
        display(strLabel, "Hmmm...");
    public static void display(JComponent comp, String title) {
        JFrame f = new JFrame(title);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().add(comp);
        f.pack();
        f.setLocationRelativeTo(null);
        f.setVisible(true);
}

Similar Messages

  • How to store multiline string literal in to java bean shell variable

    Hello Experts
    How to store multiline string literals in java bean shell like we use triple quote for jython variable
    Using Jython
    str=""" helllo
    welcome to my world"""
    above syntax is working but not for java bean shell like below
    String str=""" hello
    welcome to my world""";
    So how to do this in java bean shell. I came to this scenario while storing logs to a variable. I believe there is no solution for storing multiline strings to java bean shell variable.
    <@
    String str="<%=odiRef.getPrevStepLog("MESSAGE")%>";
    @>
    Any suggestion will be highly appreciated.
    Thank You.

    maddythehunk wrote:
    Im trying this but its not working...
    while(billingQueryParamsItr.hasNext()) {
         billingQueryParam = (BillingQueryParam) billingQueryParamsItr.next();
         System.out.println("****** Param Name-->"+billingQueryParam.getParamName());
         String[0] name = billingQueryParam.getParamName(); // giving error ; expected
         //billingItemActionForm.setParamName(billingQueryParam.getParamName());
    Declare the array outside of the loop. Fill the array as you iterate. And stop putting your error messages inside of comments in the code.

  • How to write multiline text

    Somebody please tell me how do i write a multiline Text2d/3d in java3d.
    Thanks in advance

    Anyone manage to solve this ?
    Regards,
    Oakwd

  • How to write a string into an XML

    I wrote a web service to receive a string and write to Oracle Application Server as XML Document. But It is not writing anything. Below is writer program. What do I need to add to make it work
    public class Writer
    public Writer()
    } public void WriteHabFile(String out, String fileName)
    XMLDocument doc = new XMLDocument();
    try
    XMLPrintDriver output=new XMLPrintDriver(new FileOutputStream(new File(fileName)));
    output.setEncoding("utf-8");
    output.printDocument(doc);
    output.close();
    catch (Exception e)
    System.out.println(e.toString());
    public void WriteLanFile(String out2, String fileName2)
    XMLDocument doc = new XMLDocument();
    try
    XMLPrintDriver output=new XMLPrintDriver(new FileOutputStream(new File(fileName2)));
    output.setEncoding("utf-8");
    output.printDocument(doc);
    output.close();
    catch (Exception e)
    System.out.println(e.toString());
    Any help would be greatly appreciated.

    Why don't you try something like:
    public class Writer {
    public Writer(){}
    public void WriteHabFile(String out, String fileName) {
         oracle.xml.parser.v2.DOMParser parser = new oracle.xml.parser.v2.DOMParser();
         try {
              parser.parse(new BufferedReader(new StringReader(out)));
         catch(XMLParseException xe) {
              // Do Something
         catch(SAXException se) {
              // Do Something
         catch(IOException ie) {
              // Do Something
         XMLDocument doc = parser.getDocument();
    try {
    XMLPrintDriver output=new XMLPrintDriver(new FileOutputStream(new File(fileName)));
    output.setEncoding("utf-8");
    output.printDocument(doc);
    output.close();
    catch (Exception e)
    System.out.println(e.toString());
    public void WriteLanFile(String out2, String fileName2) {
         oracle.xml.parser.v2.DOMParser parser = new oracle.xml.parser.v2.DOMParser();
         try {
              parser.parse(new BufferedReader(new StringReader(out)));
         catch(XMLParseException xe) {
              // Do Something
         catch(SAXException se) {
              // Do Something
         catch(IOException ie) {
              // Do Something
         XMLDocument doc = parser.getDocument();
    try {
    XMLPrintDriver output=new XMLPrintDriver(new FileOutputStream(new File(fileName2)));
    output.setEncoding("utf-8");
    output.printDocument(doc);
    output.close();
    catch (Exception e)
    System.out.println(e.toString());
    Hope this helps,
    Mark Brown

  • How to write a string a stringbuffer to a text file or read a file?

    I need create a text file if the file is not exist, if exist, I have to append a string or stringbuffer to the file. Basically I am using java server page for our web application. I need send user input into a text file. I am uploading my JSP into a server, and run JSP from server. I wonder if I want to create a file, where this file goes, and how can I specify the path of the file?
    I used: BufferedReader br = new BufferedReader( new FileReader("report.txt"));
    The file report.txt could not be found.
    Please help me, thank you so much

    Try
    File file = new File("report.txt");
    out.println("File name: "+file.getAbsolutePath());in your jsp page, then you will see where it would be placed it you created it.
    You can specify the full path like this:
    File wFile = new File("c:\\temp\\report.txt"); // for windows
    File uFile = new File("/tmp/report.txt"); // for unix/linux
    // or
    File file = new File(myPath, "report.txt"); // where myPath is the path where you want to place report.txt.You can either use a File object or String object in the FileReader constructor..
    If you just want to know if the file exits, then use a file object and call exists() on it, returns true if the file already exist. If you want to create the file if it doesn't exit and append a string, then you don't need to check if it exist first. Just do it like this:
    PrintStream ps = new PrintStream(new FileOutputStream("report.txt", true), true);
    // again you could use a file object instead of a string with the file name
    ps.println("Add this line");
    ps.close();If the file doesn't exist, it will create it for you. The second argument in FileOutputStream means "append", and the second argument in PrintStream means "autoflush" every time you use the println methods (or add a newline '\n').

  • How to write a string   as an XML Document

    I wrote a web service to receieve a string and then write as an XMl document . But In my writer.java program, I am not doing something right. Please let me know what I am doing wrong.
    Below is writer program:
    public class Writer
    public Writer()
    } public void WriteHabFile(String out, String fileName)
    XMLDocument doc = new XMLDocument();
    try
    XMLPrintDriver output=new XMLPrintDriver(new FileOutputStream(new File(fileName)));
    output.setEncoding("utf-8");
    output.printDocument(doc);
    output.close();
    catch (Exception e)
    System.out.println(e.toString());
    public void WriteLanFile(String out2, String fileName2)
    XMLDocument doc = new XMLDocument();
    try
    XMLPrintDriver output=new XMLPrintDriver(new FileOutputStream(new File(fileName2)));
    output.setEncoding("utf-8");
    output.printDocument(doc);
    output.close();
    catch (Exception e)
    System.out.println(e.toString());
    }

    The problems is that your XML document is not parsed.

  • How to write a string into a file in java

    Say i hv a string named str.......plz give the total code of creating a file and writing the string into it

    This is the function where i am trying to write a file....i hv highlighted the regions where file writing codes are used........kindly suggest where is my mistake as this code is running but not writing anything.........only the file is getting created but nothing is getting written...aslo i havnt put fw.close() here where in the code should I put it
    static void func1(String str) throws IOException
    int i=0,j=0,k=1,m=0;
    int size1=0,file_size=0;
    String str1;
    int arr[]= new int[no_of_lines+1];
    FileWriter fw;
    *try{*
    fw=new FileWriter("output.txt");
    catch(IOException exc)
    System.out.println("Cannot open file");
    return;
    arr[0]=0;
    while(true)
    a=svcRand.nextInt(10);
    k++;
    i=0;
    j++;
    try{
    FileReader fr= new FileReader(str);
    BufferedReader br= new BufferedReader(fr);
    while((str1=br.readLine()) !=null)
    i++;
    if(i==a)
    file_size=func2(str1,size1);
    str1=str1+"\r\n";
    fw.write(str1);
    catch(FileNotFoundException exc)
    System.out.println("File not found");
    return;
    catch(ArrayIndexOutOfBoundsException exc)
    System.out.println("Usage: Showfile file");
    return;

  • Write a string to a v_path pointer

    Hi,
    Could anybody show me how to write a string to a v_path pointer of a vnode?
    Below is what I want to do:
    > 00000300245f53c0::print vnode_t v_path
    v_path = 0x300128e5aa0 "/opt/bns/k2/V6.0/script"
    > 0x300128e5aa0/W "new_path_name"
    mdb: failed to dereference symbol: unknown symbol name
    mdb: failed to write "new_path_name": failed to evaluate command
    But it gave me error message.
    Please help.
    Thanks
    Alex

    There is no write string in mdb so need to do it char by char using ascii codes.
    0x300123e8a80::print vnode_t v_path
    v_path = 0x30007e56d68 "/usr/bin/vi"
    0x30007e56d68,0t11/B
    0x30007e56d68: 2f 75 73 72 2f 62 69 6e 2f 76 69
    0x30007e56d68/v 2f 65 74 63
    0x30007e56d68: 0x2f = 0x2f
    0x30007e56d69: 0x75 = 0x65
    0x30007e56d6a: 0x73 = 0x74
    0x30007e56d6b: 0x72 = 0x63
    0x300123e8a80::print vnode_t v_path
    v_path = 0x30007e56d68 "/etc/bin/vi"
    No idea why you would want too.
    Edited by: .robv. on 10-Nov-2009 13:41

  • Using CLOB as a VARCHAR2 to write a string

    Hello everyone:
    I have this situation:
    After a query, i need to order the query rows in a table. To do this, i write a string using HTML format. Then, i send the string (message) by email, and i save the same in a table (database).
    The message, must be 32767 as a maximun number of characters. Because, the message is a VARCHAR2.
    When the number of characters is greater than 32767, in can't use this way.
    So, i trying to use a CLOB datatype, but i don't know how to write the string and then, send it by email.
    I wrote this code:
    xSGLOSA_UNO$ CLOB;
    xSGLOSA_UNO$ := '<table border="1"><tr>FECHA DE PROCESOS CORRECTAS</tr>';
    xSGLOSA_UNO$ := xSGLOSA_UNO$ || '<tr><td>Rut Operador</td><td>Nombre</td><td>Proceso</td><td>Fecha Proceso</td></tr>';
    BEGIN
    FOR CONSULTA_UNO IN(
    SELECT
    FPR_NRUTOPERADOR,
    OPE_SNOMBRE,
    FPR_SCODPROCESO,
    FPR_DFHOPROCESO
    FROM
    FECHAS_PROCESO,
    OPERADOR
    WHERE
    TRUNC(FPR_DFHOPROCESO) = TRUNC(SYSDATE)
    LOOP
    xSGLOSA_UNO$ := xSGLOSA_UNO$ ||  '<tr><td>' || CONSULTA_UNO.FPR_NRUTOPERADOR || '</td><td>' || CONSULTA_UNO.OPE_SNOMBRE || '</td><td>' || CONSULTA_UNO.FPR_SCODPROCESO || '</td><td>' || CONSULTA_UNO.FPR_DFHOPROCESO || '</td></tr>';
    END LOOP;
    xSGLOSA_UNO$ := xSGLOSA_UNO$ || '</table>';
    EXCEPTION
    WHEN OTHERS THEN
    NUMERROR$ := SQLCODE;
    MSJERROR$ := '[NES$FECHA_PROCESOS] FECHAS CORRECTAS (' || SQLERRM || ')';
    RETURN;
    END;
    And i have this error:
    [NUMERROR$:=-6502], [MSJERROR$:=[NES$FECHA_PROCESOS] FECHAS CORRECTAS (ORA-06502: PL/SQL: error  numérico o de valor)]
    Please, help me with this issue. I am new in Oracle, and i don't have idea the real reason for this.
    Thank you for support.

    Now... when you do things like:
    xSGLOSA_UNO$ := xSGLOSA_UNO$ || '</table>';
    then you are concatenating a CLOB (xSGLOSA_UNO$) to a VARCHAR2 ('</table>') which can be done by either convert the clob to varchar2 or the varchar2 to clob before concatenating. || is a overloaded function which accepts two varchar2 or two clob parameters (amongst others). As the CLOB gets bigger than 32k you cannot just let oracle decide how to convert so, you should do:
    xSGLOSA_UNO$ := xSGLOSA_UNO$ || TO_CLOB('</table>');
    instead.
    And this at every place where you concatenate
    eg here too:
    xSGLOSA_UNO$ := xSGLOSA_UNO$ || TO_CLOB('<tr><td>') || CONSULTA_UNO.FPR_NRUTOPERADOR || TO_CLOB('</td><td>') || CONSULTA_UNO.OPE_SNOMBRE || TO_CLOB('</td><td>') || CONSULTA_UNO.FPR_SCODPROCESO || TO_CLOB('</td><td>') || CONSULTA_UNO.FPR_DFHOPROCESO || TO_CLOB('</td></tr>');
    I don't know the datatypes of CONSULTA_UNO.FPR_NRUTOPERADOR and the other components used...if they are VARCHAR then convert, if they are CLOB then let them like they are.
    hth

  • How to write a specific bytes of a string

    I'm using DataOutputStream object to write a specific string to a file. If I want to write that string
    to a file with preserving of 20 bytes (for example) as a header of the file. Even though the length of the string can be at any size, I just want it alwayst in 20 bytes. How could I do that. Please help! Thanks a lot.

    String s = "Less than 20";
    while(s.length() < 20) {
         s += " ";
    System.out.println(s + " " + s.length());Mark

  • How to read and write a string into a txt.file

    Hi, I am now using BEA Workshop for Weblogic Platform version10. I am using J2EE is my programming language. The problem I encounter is as the above title; how to read and write a string into a txt.file with a specific root directory? Do you have any sample codes to reference?
    I hope someone can answer my question as soon as possible
    Thank you very much.

    Accessing the file system directly from a web app is a bad idea for several reasons. See http://weblogs.java.net/blog/simongbrown/archive/2003/10/file_access_in.html for a great discussion of the topic.
    On Weblogic there seems to be two ways to access files. First, use a File T3 connector from the console. Second, use java.net.URL with the file: protocol. The T3File object has been deprecated and suggests:
    Deprecated in WebLogic Server 6.1. Use java.net.URL.openConnection() instead.
    Edited by: m0smith on Mar 12, 2008 5:18 PM

  • How to write the map expression for a const string

    hi all,
    i am trying to map from source table A to target table B. Table B has a column that A doesn't have and the column type is string.
    what should i do if i want to keep this column a const string like "abc"? How to write the map expression?
    Setting a default value like "abc" of this column in database is not available .
    please try to help, thanks a lot.
    jun

    Hi jun,
    You mean, u want to give some hard coded value to a specific column in mapping?
    If so , give 'abc' in the target column and execute it on Target.
    Thanks,
    Guru

  • How to write regular expression to find desired string piece *duplicate*

    Hi All,
    Suppose that i have following string piece:
    name:ali#lastname:kemal#name:mehmet#lastname:cemalI need
    ali
    mehmetI use following statement
    SQL> select lst, regexp_replace(lst,'(name:)(.*)(lastname)(.*)','\2',1,1) nm from (
      2    select 'name:ali#lastname:kemal#name:mehmet#lastname:cemal' as lst from dual
      3  );
    LST                                                NM
    name:ali#lastname:kemal#name:mehmet#lastname:cemal ali#lastname:kemal#name:mehmet#
    SQL> But it does not return names correctly. When i change 5th parameter(occurence) of regexp_replace built-in function(e.g. 1,2), i may get ali and mehmet respectiveley.
    Any ideas about regexp?
    Note : I can use PL/SQL instr/substr for this manner; but i do not want to use them. I need regexp.
    Regards...
    Mennan
    Edited by: mennan on Jul 4, 2010 9:53 PM
    thread was posted twice due to chrome refresfment. Please ignore the thread and reply to How to write regular expression to find desired string piece

    The approach is to do cartesian join to a 'number' table returning number of records equal to number of names in the string.I have hardcoded 2 but you can use regexp_count to get the number of occurrences of the pattern in the string and then use level <=regexp_count(..... .
    See below for the approach
    with cte as(
    select
    'name:ali#lastname:kemal#name:mehmet#lastname:cemal' col ,level lev
    from dual connect by level <=2)
    select substr(regexp_substr('#'||col,'#name:\w+',1,lev),7)
    from cte
    /

  • HOW DO I WRITE A STRING TO FLAG WHEN A CELL HAS OR 17 CHARACTERS?

    HOW DO I WRITE A STRING TO FLAG WHEN A CELL HAS < OR > 17 CHARACTERS?

    Hi Tassytiger,
    A "string" is just a string of characters. Examples are qwerty, 123abc, 43πbono. there are several ways to write one. A more precise description of your end goal might help answer "How do I write a string."
    To the current version of your specific question:
    What I actually need to achieve is a situation where, when I enter <17 Char. or >17 Char.
    inadvertently then tab to the next cell, I get the following response in the active cell:
    The cell immediately below "17 character ID" displays an error triangle. These are shown when the formula in a cell produces an error message. they are system generated and require two things to happen: The cell must contain a formula AND something must have happened to cause that formula to produce an error.
    I don't wish to add any columns to my s/s but would like to apply the rule to the current column just as i would change the text or fill colour.
    The difficulty there is that a cell may contain entered data, OR it may contain a formula. You want to enter data (a string of characters) and you want to produce an error triangle if that string has more or fewer than 17 characters. Evaluating the length of the string requires a formula. Getting the string into the cell requires direct entry (in your scenario). The two are not compatible within the content of a single cell.
    Terry's example uses a formula in column B to measure the length of the string in column A. If the length is 17 characters, the IF statement produces the empty string ( "" ), and the cell in column B appears empty. If the string is not 17 characters long, the IF statement produces the string "Not 17 Chars!"
    His formula is easily changed to produce an error triangle in place of "Not 17 Chars!":
    B1: =IF(LEN(A1)=17, "",17/0)
    In this version, if the length of the string in A1 is not 17 (characters), the formula will attempt to divide 17 by 0, and will produce a 'division by zero' error.
    But, as with all of the other suggestions, this one will require a new column to provide space for the formula and it's result.
    Changing the text or fill colour can be done using conditional formatting. Changing content of the cell (eg. choosing between the entered string of characters and the error triangle) cannot.
    Conditional formatting rules compare the content of a the cell to be formatted with either a fixed value (written into the rule) or to the content of another cell. In my examples (and in Ian's examples) above the rules compared the content of the cell to be formattes to the number '17'. The number was generated by a formula which measured the length (in characters) of the text in the cell where the ID was entered, and reported that length as a number.
    A way to show a red triangle using conditional formatting is to use Image fill as the default fill of the cell, then use a colour fill as the conditional fill to hide the trialngle when the conditions are met. Here's the same example as used above, with this technique applied to column B:
    The same formula is used in column B as in my previous example. Type size is set to 1 point (note the black dot, visible in the green filled cell) to keep the numbers from obscuring the triangles. The triangles are shapes, inserted onto the canvas (not into the table) from the Shapes button in the tools. Their fill colour has been changed to red, a 12 point exclamation sign character ha been typed into the shape and its text colour set to white, and the triangle's size has been reduced as much as possible without triggering the overflow symbol (boxed plus sigh) to appear.
    The triangle image (and some of its white background) was made into a png image file by taking a screen shot, and the image was inserted into all of the cells in the body rows of column B as an image fill, using the Graphic inspector. The conditional format rule below was then applied to the body row cells in column B.
    Finally, you can apply conditional formatting to the cell containing the ID. This will still require another column to contain the values to which the content of the ID cell will be compared, but that column may be hidden, or may be located on a separate table.
    The method requires an second cell for each cell contining an ID, and uses a formula that makes the contents of the second cell the same as that of the ID cell IF the ID cell contents are 17 characters long.
    Here's a sample. Table 1 is column A of the same table as above. Table 2 is a single column table holding the comparison cells.
    As in the example above, the cells on table 1 were given an image fill. The conditional format rule replaces that with a white colour fill when the cell contains the same text as its partner cell in Table 2.
    This is the rule for cell A2. In A3, the cell reference is to Table 2::A3, and in A4, to Table 2::A4. The cell references in conditional format rules must be edited individually.
    Regards,
    Barry

  • How can i write a string into a specified pos of a file?

    How can i write a string into a specified pos of a file without read all file into ram and write the whole file again?
    for example:
    the content of file is:
    name=123
    state=456
    i want to modify the value of name with 789
    (write to file without read all file into ram)
    How can i do it? thank you

    take this as an idea. it actually does what i decribed above. you sure need to make some modifications so it works for your special need. If you use it and add any valuable code to it or find any bugs, please let me know.
    import java.io.*;
    import java.util.*;
    * Copyright (c) 2002 Frank Fischer <[email protected]>
    * All rights reserved. See the LICENSE for usage conditions
    * ObjectProperties.java
    * version 1.0, 2002-09-12
    * author Frank Fischer <[email protected]>
    public class ObjectProperties
         // the seperator between the param-name and the value in the prooperties file
         private static final String separator = "=";
         // the vector where we put the arrays in
         private Vector PropertiesSet;
         // the array where we put the param/value pairs in
         private String propvaluepair[][];
         // the name of the object the properties file is for
         public String ObjectPropertiesFileName;
         // the path to the object'a properties file
         public String ObjectPropertiesDir;
         // reference to the properties file
         public File PropertiesFile;
         // sign for linebreak - depends on platforms
         public static final String newline = System.getProperty("line.separator");
         public ObjectProperties(String ObjectPropertiesFileName, String ObjectPropertiesDir, ObjectPropertiesManager ObjectPropertiesManager)
         //     System.out.println("Properties Objekt wird erzeugt: "+ObjectPropertiesFileName);
              this.ObjectPropertiesFileName = ObjectPropertiesFileName;
              this.ObjectPropertiesDir = ObjectPropertiesDir;
              // reference to the properties file
              PropertiesFile = new File(ObjectPropertiesDir+ObjectPropertiesFileName);
              // vector to put the param/value pair-array in
              PropertiesSet = new Vector();
         //     System.out.println("Properties File Backup wird erzeugt: "+name);
              backup();
         //     System.out.println("Properties File wird eingelesen: "+PropertiesFile);
              try
                   //opening stream to file for read operations
                   FileInputStream FileInput = new FileInputStream(PropertiesFile);
                   DataInputStream DataInput = new DataInputStream(FileInput);
                   String line = "";
                   //reading line after line of the properties file
                   while ((line = DataInput.readLine()) != null)
                        //just making sure there are no whitespaces at the beginng or end of the line
                        line = cutSpaces(line);
                        if (line.length() > 0)
                             //$ indicates a param-name
                             if (line.startsWith("$"))
                                  // array to store a param/value pair in
                                  propvaluepair = new String[1][2];
                                  //get the param-name
                                  String parameter = line.substring(1, line.indexOf(separator)-1);
                                  //just making sure there are no whitespaces at the beginng or end of the variable
                                  parameter = cutSpaces(parameter);
                                  //get the value
                                  String value = line.substring(line.indexOf(separator)+1, line.length());
                                  //just making sure there are no whitespaces at the beginng or end of the variable
                                  value = cutSpaces(value);
                                  //put the param-name and the value into an array
                                  propvaluepair[0][0] = parameter;
                                  propvaluepair[0][1] = value;
                             //     System.out.println("["+ObjectPropertiesFileName+"] key/value gefunden:"+parameter+";"+value);
                                  //and finaly put the array into the vector
                                  PropertiesSet.addElement(propvaluepair);
              // error handlig
              catch (IOException e)
                   System.out.println("ERROR occured while reading property file for: "+ObjectPropertiesFileName);
                   System.out.println("ERROR CODE: "+e);
                   // System.out.println("in ObjectProperties");
         // function to be called to get the value of a specific paramater 'param'
         // if the specific paramater is not found '-1' is returned to indicate that case
         public String getParam(String param)
              // the return value indicating that the param we are searching for is not found
              String v = "-1";
              // looking up the whole Vector
              for (int i=0; i<PropertiesSet.size(); i++)
                   //the String i want to read the values in again
                   String s[][] = new String[1][2];
                   // trying to get out the array from the vector again
                   s = (String[][]) PropertiesSet.elementAt(i);
                   // comparing the param-name we're looking for with the param-name in the array we took out the vector at position i
                   if (s[0][0].equals(param) == true)
                        //if the param-names are the same, we look up the value and write it in the return variable
                        v = s[0][1];
                        // making sure the for loop ends
                        i = PropertiesSet.size();
              // giving the value back to the calling procedure
              return v;
         // function to be called to set the value of a specific paramater 'param'
         public void setParam(String param, String value)
              // looking up the whole Vector for the specific param if existing or not
              for (int i=0; i<PropertiesSet.size(); i++)
                   //the String i want to read the values in again
                   String s[][] = (String[][]) PropertiesSet.elementAt(i);
                   // comparing the param-name we're looking for with the param-name in the array we took out the vector at position i
                   if (s[0][0].equals(param) == true)
                        //if the param-names are the same, we remove the param/value pair so we can add the new pair later in
                        PropertiesSet.removeElementAt(i);
                        // making sure the for loop ends
                        i = PropertiesSet.size();
              // if we land here, there is no such param in the Vector, either there was none form the beginng
              // or there was one but we took it out.
              // create a string array to place the param/value pair in
              String n[][] = new String[1][2];
              // add the param/value par
              n[0][0] = param;
              n[0][1] = value;
              // add the string array to the vector
              PropertiesSet.addElement(n);
         // function to save all data in the Vector to the properties file
         // must be done because properties might be changing while runtime
         // and changes are just hold in memory while runntime
         public void store()
              backup();
              String outtofile = "# file created/modified on "+createDate("-")+" "+createTime("-")+newline+newline;
              try
                   //opening stream to file for write operations
                   FileOutputStream PropertiesFileOuput = new FileOutputStream(PropertiesFile);
                   DataOutputStream PropertiesDataOutput = new DataOutputStream(PropertiesFileOuput);
                   // looping over all param/value pairs in the vector
                   for (int i=0; i<PropertiesSet.size(); i++)
                        //the String i want to read the values in
                        String s[][] = new String[1][2];
                        // trying to get out the array from the vector again
                        s = (String[][]) PropertiesSet.elementAt(i);
                        String param = "$"+s[0][0];
                        String value = s[0][1];
                        outtofile += param+" = "+value+newline;
                   outtofile += newline+"#end of file"+newline;
                   try
                        PropertiesDataOutput.writeBytes(outtofile);
                   catch (IOException e)
                        System.out.println("ERROR while writing to Properties File: "+e);
              catch (IOException e)
                   System.out.println("ERROR occured while writing to the property file for: "+ObjectPropertiesFileName);
                   System.out.println("ERROR CODE: "+e);
         // sometimes before overwritting old value it's a good idea to backup old values
         public void backup()
              try
                   // reference to the original properties file
                   File OriginalFile = new File(ObjectPropertiesDir+ObjectPropertiesFileName);
                   File BackupFile = new File(ObjectPropertiesDir+"/backup/"+ObjectPropertiesFileName+".backup");
                   //opening stream to original file for read operations
                   FileInputStream OriginalFileInput = new FileInputStream(OriginalFile);
                   DataInputStream OriginalFileDataInput = new DataInputStream(OriginalFileInput);
                   //opening stream to backup file for write operations
                   FileOutputStream BackupFileOutput = new FileOutputStream(BackupFile);
                   DataOutputStream BackupFileDataOutput = new DataOutputStream(BackupFileOutput);
              //     String content = "";
                   String line = "";
                   // do till end of file
                   while ((line = OriginalFileDataInput.readLine()) != null)
                        BackupFileDataOutput.writeBytes(line+newline);
              // error handlig
              catch (IOException e)
                   System.out.println("ERROR occured while back up for property file: "+ObjectPropertiesFileName);
                   System.out.println("ERROR CODE: "+e);
                   System.out.println("this is a serious error - the server must be stopped");
         private String cutSpaces(String s)
              while (s.startsWith(" "))
                   s = s.substring(1, s.length());
              while (s.endsWith(" "))
                   s = s.substring(0, s.length()-1);
              return s;
         public String createDate(String seperator)
              Date datum = new Date();
              String currentdatum = new String();
              int year, month, date;
              year = datum.getYear()+1900;
              month = datum.getMonth()+1;
              date = datum.getDate();
              currentdatum = ""+year+seperator;
              if (month < 10)
                   currentdatum = currentdatum+"0"+month+seperator;
              else
                   currentdatum = currentdatum+month+seperator;
              if (date < 10)
                   currentdatum = currentdatum+"0"+date;
              else
                   currentdatum = currentdatum+date;
              return currentdatum;
         public String createTime(String seperator)
              Date time = new Date();
              String currenttime = new String();
              int hours, minutes, seconds;
              hours = time.getHours();
              minutes = time.getMinutes();
              seconds = time.getSeconds();
              if (hours < 10)
                   currenttime = currenttime+"0"+hours+seperator;
              else
                   currenttime = currenttime+hours+seperator;
              if (minutes < 10)
                   currenttime = currenttime+"0"+minutes+seperator;
              else
                   currenttime = currenttime+minutes+seperator;
              if (seconds < 10)
                   currenttime = currenttime+"0"+seconds;
              else
                   currenttime = currenttime+seconds;
              return currenttime;

Maybe you are looking for

  • Mail junk not going to Junk folder

    I want mail to filter junk (including previous emails) and automatically place it in the junk folder. Currently, all it is doing is marking mail as junk within the inbox, and no junk emails are showing up in the junk folder. I tried unchecking and re

  • My external hard drive went bad and i need to reset the iCloud status within iTunes. I can't figure out how to do this. Any ideas?

    So I had most of my music on an external hard drive (Seagate even!) and it went bad, but I occationally can get some stuff off of it. When I tried to do the iTunes Match, it looked for songs on my computer and found alot not there. Now they are all s

  • New Mac Book and Photoshop Elements

    My daughter just bought a new MacBook (Mac OS X 10.5.4 2.4 Ghz Intel Core 2 Duo 2 GB 667 MHz DDR2 SDRAM) and tried to install my Photoshop Elements software onto it. My Photoshop is kind of old (Elements 2.0), but I use it on my Mac all the time with

  • Adding rights to forms programmically or thru command line

    We have the reader extension 7.0 and it comes with the web interface to add rights one file at a time. I checked the API and still not sure where to start. If somebody can shed more light I'll appreciate it. Also do I need other components to develop

  • Oracle 9ir2 on Red Hat 8

    Hello all, I'm trying to install the Ora 9ir2 on RH 8 and have had some problems. I've did the dba group, user, run the root.sh changed the shmmax to a great value as manual. But in the final of installation the procecss was failed. In fact, on the t