Str?nge char?cters in museek [solved]

this happens only in the soulseek app museek
file names which contain foreign characters (ä ö for example) appear as a question mark - ex: m?dchen instead of mädchen
this results in a file error because obviously the file names don't match.
it's simple western european characters, my system is OK (OS english, keyboard is german) and as I said it only happens in museek, however I can type the characters in chat but search results and remote files show up wacky. I already changed from 8859-1 to utf-8.
any hints fellas?

andre.ramaciotti wrote:The second problem is encryptation by itself . Let's say I have the file 'in' with 'Hello World' in it. If I use 'asd' as password, and the decrypt it, everything is fine, but if I use 'hello' as password, I can't decrypt it, it stops on H.
Your code for encrypting looks fine at first glance.  And your problem is in the decryption stage so I guess thats the code we need to see...

Similar Messages

  • On the use of VARCHAR2 vs. CHAR

    I'm posting an e-mail thread that has been moving around in my organization, whith guidance from an Oracle representative.
    The basic issue concerns the use of CHAR vs. VARCHAR2 when defining a table in Oracle.
    I would like to get some comments from the community at large.
    1. Business semantics should be represented in every aspect of a database, application, and design as far as I am concerned. Noteably, if the business rule at a corporate entity is clearly stated that when using Oracle the use of CHAR should be limited to those attribute implementations which have the following characteristics; a) The attribute may not be null, b) The attribute must have a character in each of the declared positions.
    2. When the Visual Basic application began writing data to the CHAR columns in your application someone should have had a discussion with the developer to find out why this was happening. If the business semantics changed then the logical implemention of the business semantics should have changed as well. That the two were disconnected is not a problem with the CHAR type, it is a problem with the designer or the developer. The bottom line on this instance is that the column should have been defined as a VARCHAR2 data type since the business semantics no longer complied with the criteria set forth in the previous paragraph.
    3. I think Oracle trys to load as much of the data from a table or index into shared memory, in this case the database block buffers, as it can in order to facilitate query operations. If Oracle has enough memory and can load a table or index into memory, it will do so. At the same time the database engine will move previously cached data out of memory to accommodate the new requirement.
    -----Original Message-----
    Thank you for the detail information on CHAR and VARCHAR2. It got me thinking with a DBA hat. I worked as a DBA before and I did use the CHAR type and I will share my experience/thought on CHAR.
    I don't like to use the char type like Tom has advised because Oracle does not check to see if the value being inserted fills up the column or not which can lead to a problem. And there is no performance gain or save space in Oracle.
    I worked as a DBA before, I used char type on the "must fill/always filled" column (pre DMDC). The application was written in VB with Oracle back end. At some point, VB started inserting values that are short of the column width and created a minor problem (it was supposed to be filled column). The problem was quickly identified and fixed, but it caused an issue.
    I realize that I don’t want to define it as a "must fill/always filled" column if you can't enforce it by simply defining the char data type on a table and prevent possible issue in the future.
    For a manager, in order to use the char properly, you have to hire client developers with Oracle experience or provide a basic Oracle training in order to avoid the problem I mentioned above in order to use the char type correctly.
    I think you, Tom and I are saying the same thing really. Only difference is that Tom and I can not think of a good reason why anyone would like to indicate the business semantics using column type on the database, when it can lead to more work/issues.
    In regards to wasted 25 million byes, why would Oracle load the table with 25 million rows? Shouldn't it use an index? Don't you have a serious problem if Oracle is loading table with the 25 million rows?
    Just my two cents... : )
    -----Original Message-----
    May I beg to differ?
    CHAR plays a vital role in the intuitive interpretation of a database schema. If designed correctly, the use of CHAR tells anyone who is in the know that this is a must fill column. Thus if a column is defined as CHAR(3) everyone should know that the column will always contain three characters. Defining the column as VARCHAR2(3) does not tell you anything about the data other than that the column may contain 0-3 characters.
    Also, If a column is defined as CHAR the column should always be populated. One of the nice features of VARCHAR2 is that if the column is defined at the end of a table, there is no storage overhead until that column is actually populated. Thus if you have a table that has an identifier that is nine characters in length and will always be populated with nine characters, an attribute which describes the type of identifier which is contained in the first column and which must always be populated and is a must fill attribute, and another column which is descriptive and may vary in length or not be populated at time of insert; the following definition does not express the business semantics of the entity:
    COL_CD VARCHAR2(9)
    COL_TYP_TXT VARCHAR2(26)
    COL_TYP_CD VARCHAR2(2)
    The above definition also does not take advantage of inherent storage features of Oracle; notably there is a wasted place holder between COL_CD and COL_TYP_TXT and between COL_TYP_TXT and COL_TYP_CD. The next definition does take advantage of the storage features but does not represent the business semantics of the entity:
    COL_CD VARCHAR2(9)
    COL_TYP_CD VARCHAR2(2)
    COL_TYP_TXT VARCHAR2(26)
    The above definition does not waste space storing a place holder between COL_TYP_CD and COL_TYP_TXT if the COL_TYP_TXT may be null. The column separator will only be used when the column contains data. The below definition satisfies both the storage and business semantics issues:
    COL_CD CHAR(9)
    COL_TYP_CD CHAR(2)
    COL_TYP_TXT VARCHAR2(26)
    This may seem pedantic in nature until you consider the situation where there are 25 million rows in the table represented by the above entity. If each row has a NULL COL_TYP_TXT value then the first example wasted 25 million bytes of storage and 25 million bytes of memory if the full table is loaded into memory. This is an issue which cannot be ignored in high volume databases.
    You may wish to know why it is important to define a must fill/always fill column as a CHAR to express the business semantics of an attribute. I can't give a definitive answer to that other than to say that it is just good database manners.
    So please, continue to use CHAR when the shoe fits. Don't throw something away that has use just because it is not popular or in the mode.
    Also, if I am mistaken in any of the above, please feel free to educate me.
    Thanks.
    -----Original Message-----
    Subject: RE: Oracle on the use of VARCHAR2 vs. CHAR
    Ignore if you already got this. This is just FYI.
    -----Original Message-----
    Below is a detailed answer to your VARCHAR2 or CHAR questions from our Database expert Tom Kyte. The short answer is VARCHAR2 is what you want to use. If you have any questions or want to discuss this in more detail let me know.
    A CHAR datatype and VARCHAR2 datatype are stored identically (eg: the word 'WORD' stored in a CHAR(4) and a varchar2(4) consume exactly the same amount of space on disk, both have leading byte counts).
    The difference between a CHAR and a VARCHAR is that a CHAR(n) will ALWAYS be N bytes long, it will be blank padded upon insert to ensure this. A varchar2(n) on the other hand will be 1 to N bytes long, it will NOT be blank padded.
    Using a CHAR on a varying width field can be a pain due to the search semantics of CHAR.
    Consider the following examples:
    ops$tkyte@8i> create table t ( x char(10) ); Table created.
    ops$tkyte@8i> insert into t values ( 'Hello' );
    1 row created.
    ops$tkyte@8i> select * from t where x = 'Hello';
    X
    Hello
    ops$tkyte@8i> variable y varchar2(25)
    ops$tkyte@8i> exec :y := 'Hello'
    PL/SQL procedure successfully completed.
    ops$tkyte@8i> select * from t where x = :y; no rows selected
    ops$tkyte@8i> select * from t where x = rpad(:y,10);
    X
    Hello
    Notice how when doing the search with a varchar2 variable (almost every tool in the world uses this type), we have to rpad() it to get a hit.
    If the field is in fact ALWAYS 10 bytes long, using a CHAR will not hurt -- HOWEVER, it will not help either.
    The only time I personally use a CHAR type is for CHAR(1). And that is only because its faster to type char(1) then varchar2(1) -- it offers no advantages.
    If you just use varchar2 everywhere, no problem
    My advice is, has been, will be very loudly stated as:
    IGNORE THE EXISTENCE OF CHAR.
    period. If you never use char, you never compare char to varchar2, problem solved.
    And if you use char and compare a char(n) to a char(m) they will never compare either.
    Just say NO TO CHAR.
    **************************************************

    Hi,
    >>A CHAR datatype and VARCHAR2 datatype are stored identically (eg: the word 'WORD' stored in a CHAR(4) and a varchar2(4) consume exactly the same amount of space on disk, both have leading byte counts).
    Ok, but on the other hands:
    SGMS@ORACLE10> create table x (name char(10), name2 varchar2(10));
    Table created.
    SGMS@ORACLE10> insert into  x values ('hello','hello');
    1 row created.
    SGMS@ORACLE10> commit;
    Commit complete.
    SGMS@ORACLE10> select vsize(name),vsize(name2) from x;
    VSIZE(NAME) VSIZE(NAME2)
             10            5
    SGMS@ORACLE10> select dump(name),dump(name2) from x;
    DUMP(NAME)                                         DUMP(NAME2)
    Typ=96 Len=10: 104,101,108,108,111,32,32,32,32,32  Typ=1 Len=5: 104,101,108,108,111Cheers

  • Regex and Extended Chars

    Hey guys,
    I am looking for a regex that will allow only ascii chars and not extended chars. Can someone please help me out with that? I have written this bit of code that will remove extended ascii chars but I was looking for a regex. Any ideas?
      //this is what I have to remove ascii chars.
       public static void main(String[] args){
            String str = "123asd.32#$%^&*()_+={}|\\;";
            str +=  (char)128;
            str +=  (char)129;
            str +=  (char)130;
            str +=  (char)131;
            str +=  (char)132;
            System.out.println(str);
            str = removeExtenedChars(str);
            System.out.println(str);
       public static String removeExtenedChars(String str){
            StringBuffer sb = new StringBuffer();
            StringCharacterIterator it = new StringCharacterIterator(str);
            for(char c = it.first(); c != CharacterIterator.DONE;c = it.next() ){
               int asciiVal = (int)c;
               if(asciiVal > 0 && asciiVal < 128){
                    sb.append(c);
            return sb.toString();
       }

    String asciiOnly = "your string".replaceAll("[^\u0000-\u007f]+","");

  • Boolean, comparing user string & user char

    I'm missing something. i'm trying to compare a string, from user input, to a char, from user input. Ex. string, char: "sssss" "s". Solving for does string "sssss" contain only char "s" ? In this case, should return true. In "ssss sd" "s" SOP should retun false false. I'm having trouble writing code so that string "s", however many, = char "s". Probably confusing, I'm sorry. Here's what I have:
    //     StringInput.java          
    public class StringInput
         public static void main(String[] args)
         String s = args[0];          //get the String from the user
         char c = args[1].charAt(0);     //get the char from the user
         int i = 0;
         boolean answer = true;{
         while (answer && (i < s.length () - 1)) {
    //char c = s.charAt (i);
         //if (! (((c >= '0') && (c <= s.length)) || (c == ' ')))
         answer = false; }}
         String trim = s.trim();
         s = trim;
         String replace = s.replace('a', 's');
         int length = s.length();
         System.out.println (trim);
         System.out.println (replace);
         System.out.println (length);
    System.out.println("The String " + s + " is composed " + " entirely of the char " + c + ": " + answer);                          

    This might work
    class ScanInput
         public static void main(String[] args)
              String s = args[0]; //get the String from the user
              char c = args[1].charAt(0); //get the char from the user
              boolean answer = false;
              int i =0;
              while ( (! answer) && ( i < s.length( ) -  1 )  )
                        if ( c != s.charAt( i ) )
                                  answer = true;
                        i++;
              if ( answer)
                        System.out.println(" The input string " + s + " contains other characters besides " + c );
              else
                        System.out.println(" The input string " + s + " contains only character " + c );
    }

  • Nontyp template argument, char[] vs char*

    Hi
    I just tried to compile this example
    #include <iostream>
    using namespace std;
    template <const char *str>
    struct xyz
      const char *p;
      xyz() : p(str) { }
      void print() { cout << str << endl; }
    char Comeau[] = "Comeau C++";
    int main()
      xyz<Comeau> x; // Now ok
      x.print();
    }(slightly modified to be standalone, from here:
    http://www.comeaucomputing.com/techtalk/templates/)
    It compiles and runs OK with GCC 4.0.2. With
    CC: Sun Ceres C++ 5.10 SunOS_sparc 2009/03/06
    I get
    CC -library=stlport4 +w2 bad_template.cpp -o bad_template
    "bad_template.cpp", line 17: Error: Template parameter str requires an expression of type const char*.
    1 Error(s) detected.
    Is there a workaround for this?
    Paul

    It's a compiler bug. Please file a bug report on the C++ compiler at [http://bugs.sun.com]
    A possible workaround is to declare Comeau as extern const. (Plain const would make it static.):
    extern const char Comeau[] = "Comeau C++"; You would not be able to modify the array, of course.

  • Error in using  the title of the JFrame window as handle

    Hello,
    To get the handle of JFrame, i used FindWindow. I used as given below in JNI.
    JNIEXPORT void JNICALL
    Java_T_Tmanager_init1(JNIEnv *env, jclass cla,jstring str)
    const char* cw = env->GetStringUTFChars(str, 0);
         HWND hwnd = FindWindow(NULL,cw);
         env->ReleaseStringUTFChars(str, cw);
         InitTwain(hwnd);
    When i tried to create dll file, it is showing the following error :
    TmanagerImpl1.obj : error LNK2001 : unresolved external symbol impFindWindowA@8
    sample.dll: fatal error LNK1120 : 1 unresolved externals
    How to solve this problem? Help me in solving this.
    Thanks,
    Sri

    plz help me !!!!!

  • Specifying screen coordinate​s in printf using LabView RT 2009

    According to the help documentation in LabView 2011 "Printf (LabVIEW Manager Function)", the conversion character of 'q' is supposed to reference a point. The actual help text is "q Point (passed by value) as %d,%d representing horizontal, vertical coordinates". Is this a valid conversion character for LabView RT 2009? If so, then does anyone have an example of using these characters to print at row 10, column 1 on the console? I'm tried many combinations like: printf("%dqTest Row",(10,1)), etc.
    Solved!
    Go to Solution.

    LabVIEW Real-Time does not inherently have a "console" - it has an "output stream".  There is no published API to allow you to jump around on the console natively (don't cross the streams) - you can't even do it with the LabVIEW Manager functions (it literally prints a dot in that pixel location, not text).  
    Now, I didn't tell you this, but if you happen to have a target with video memory (like a PXI system, definitely NOT a cRIO or cFP) and you happen to know the address of where video memory sits on your system <cough> 0x0B8000 </cough>, you can directly write ascii characters to specific areas on the screen - just like they did back in the DOS days.  
    #include <iostream>
    #include <windows.h>
    void VGAChar(unsigned int row, unsigned int col, char c, unsigned char attr) {
    static volatile char *video_mem = (char *)0x0B8000;
    unsigned int pos = ((row * 80) + col)*2;
    video_mem[pos] = c;
    video_mem[pos+1] = attr;
    void VGAString( unsigned int row, unsigned int col, char * str, unsigned char attr) {
    int i = 0;
    while (str[i] != '\0')
    VGAChar(row+(col+i)/80, (col+i)%80, str[i], attr); /* print each character */
    i++;
    int main (void)
    char buffer[ 100 ];
    sprintf( buffer, "Hello, my DOS world!" );
    VGAString( 10, 10, buffer, FOREGROUND_BLUE | FOREGROUND_RED ); // prints in PURPLE at ROW 10, COL 10.
    return 0;
     Of course I don't condone this, and it's definitely NOT supported (and only works on PharLap-based targets with a video console), but it IS a lot of fun.  
    -Danny

  • Problem with addRow and MultiLine Cell renderer

    Hi ,
    Ive a problem with no solution to me .......
    Ive seen in the forum and Ivent found an answer.......
    The problem is this:
    Ive a JTable with a custom model and I use a custom multiline cell renderer.
    (becuse in the real application "way" hasnt static lenght)
    When I add the first row all seem to be ok.....
    when I try to add more row I obtain :
    java.lang.ArrayIndexOutOfBoundsException: 1
    at javax.swing.SizeSequence.insertEntries(SizeSequence.java:332)
    at javax.swing.JTable.tableRowsInserted(JTable.java:2926)
    at javax.swing.JTable.tableChanged(JTable.java:2858)
    at javax.swing.table.AbstractTableModel.fireTableChanged(AbstractTableMo
    del.java:280)
    at javax.swing.table.AbstractTableModel.fireTableRowsInserted(AbstractTa
    bleModel.java:215)
    at TableDemo$MyTableModel.addRow(TableDemo.java:103)
    at TableDemo$2.actionPerformed(TableDemo.java:256)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
    64)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
    ctButton.java:1817)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
    .java:419)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
    istener.java:245)
    at java.awt.Component.processMouseEvent(Component.java:5134)
    at java.awt.Component.processEvent(Component.java:4931)
    at java.awt.Container.processEvent(Container.java:1566)
    at java.awt.Component.dispatchEventImpl(Component.java:3639)
    at java.awt.Container.dispatchEventImpl(Container.java:1623)
    at java.awt.Component.dispatchEvent(Component.java:3480)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
    at java.awt.Container.dispatchEventImpl(Container.java:1609)
    at java.awt.Window.dispatchEventImpl(Window.java:1590)
    at java.awt.Component.dispatchEvent(Component.java:3480)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
    read.java:197)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
    ad.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
    This seems to be caused by
    table.setRowHeight(row,(getPreferredSize().height+2)); (line 164 of my example code)
    About the model I think its ok.....but who knows :-(......
    Please HELP me in anyway!!!
    Example code :
    import javax.swing.*;
    import javax.swing.table.*;
    import java.text.*;
    import javax.swing.text.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class TableDemo extends JFrame {
    private boolean DEBUG = true;
    MyTableModel myModel = new MyTableModel();
    MyTable table = new MyTable(myModel);
    int i=0;
    public TableDemo() {
    super("TableDemo");
    JButton bottone = new JButton("Aggiungi 1 elemento");
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    //table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);
    //Add the scroll pane to this window.
    getContentPane().add(bottone,BorderLayout.NORTH);
    getContentPane().add(scrollPane, BorderLayout.CENTER);
    bottone.addActionListener(Add_Action);
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    class MyTable extends JTable {
    MultiLineCellRenderer multiRenderer=new MultiLineCellRenderer();
    MyTable(TableModel tm)
    super(tm);
    public TableCellRenderer getCellRenderer(int row,int col) {
              if (col==1) return multiRenderer;
              else return super.getCellRenderer(row,col);
    class MyTableModel extends AbstractTableModel {
    Vector data=new Vector();
    final String[] columnNames = {"Name",
    "Way",
    "DeadLine (ms)"
    public int getColumnCount() { return 3; }
    public int getRowCount() { return data.size(); }
    public Object getValueAt(int row, int col) {
    Vector rowdata=(Vector)data.get(row);
                                                                return rowdata.get(col); }
    public String getColumnName(int col) {
    return columnNames[col];
    public void setValueAt (Object value, int row,int col)
         //setto i dati della modifica
    Vector actrow=(Vector)data.get(row);
    actrow.set(col,value);
         this.fireTableCellUpdated(row,col);
         public Class getColumnClass(int c)
              return this.getValueAt(0,c).getClass();
         public boolean isCellEditable(int row, int col) {
    //Note that the data/cell address is constant,
    //no matter where the cell appears onscreen.
    if (col == 1)
    return false;
    else
    return true;
    public void addRow (String name,ArrayList path,Double dead) {
         Vector row =new Vector();
         row.add(name);
         row.add(path);
         row.add(dead);
         row.add(name); //!!!Mi tengo questo dato da utilizzare come key per andare a
         //prendere il path nella lista dei paths di Project
         //(needed as key to retrive data if name in col. 1 is changed)
         data.add(row);
         //Inspector.inspect(this);
         System.out.println ("Before firing Adding row...."+this.getRowCount());
         this.fireTableRowsInserted(this.getRowCount(),this.getRowCount());
    public void delRow (String namekey)
    for (int i=0;i<this.getRowCount();i++)
    if (namekey.equals(this.getValueAt(i,3)))
    data.remove(i);
    this.fireTableRowsDeleted(i,i);
    //per uscire dal ciclo
    i=this.getRowCount();
    public void delAllRows()
    int i;
    int bound =this.getRowCount();     
    for (i=0;i<bound;i++)     
         {data.remove(0);
         System.out.println ("Deleting .."+data);
    this.fireTableRowsDeleted(0,i);          
    class MultiLineCellRenderer extends JTextArea implements TableCellRenderer {
    private Hashtable rowHeights=new Hashtable();
    public MultiLineCellRenderer() {
    setEditable(false);
    setLineWrap(true);
    setWrapStyleWord(true);
    //this.setBorder(new Border(
    public Component getTableCellRendererComponent(JTable table,Object value,                              boolean isSelected, boolean hasFocus, int row, int column) {
    //System.out.println ("Renderer called"+value.getClass());
    if (value instanceof ArrayList) {
    String way=new String     (value.toString());
    setText(way);
    TableColumn thiscol=table.getColumn("Way");
    //System.out.println ("thiscol :"+thiscol.getPreferredWidth());
    //setto il size della JTextarea sulle dimensioni della colonna
    //per quanto riguarda il widht e su quelle ottenute da screen per l'height
    this.setSize(thiscol.getPreferredWidth(),this.getPreferredSize().height);
    // set the table's row height, if necessary
    //System.out.println ("Valore getPreferred.height"+getPreferredSize().height);
         if (table.getRowHeight(row)!=(this.getPreferredSize().height+2))
         {System.out.println ("Setting Row :"+row);
             System.out.println ("Dimension"+(getPreferredSize().height+2));
             System.out.println ("There are "+table.getRowCount()+"rows in the table ");
             if (row<table.getRowCount())
             table.setRowHeight(row,(getPreferredSize().height+2));
    else
    setText("");
    return this;
    /**Custom JTextField Subclass che permette all'utente di immettere solo numeri
    class WholeNumberField extends JTextField {
    private Toolkit toolkit;
    private NumberFormat integerFormatter;
    public WholeNumberField(int value, int columns) {
    super(columns);
    toolkit = Toolkit.getDefaultToolkit();
    integerFormatter = NumberFormat.getNumberInstance(Locale.US);
    integerFormatter.setParseIntegerOnly(true);
    setValue(value);
    public int getValue() {
    int retVal = 0;
    try {
    retVal = integerFormatter.parse(getText()).intValue();
    } catch (ParseException e) {
    // This should never happen because insertString allows
    // only properly formatted data to get in the field.
    toolkit.beep();
    return retVal;
    public void setValue(int value) {
    setText(integerFormatter.format(value));
    protected Document createDefaultModel() {
    return new WholeNumberDocument();
    protected class WholeNumberDocument extends PlainDocument {
    public void insertString(int offs,
    String str,
    AttributeSet a)
    throws BadLocationException {
    char[] source = str.toCharArray();
    char[] result = new char[source.length];
    int j = 0;
    for (int i = 0; i < result.length; i++) {
    if (Character.isDigit(source))
    result[j++] = source[i];
    else {
    toolkit.beep();
    System.err.println("insertString: " + source[i]);
    super.insertString(offs, new String(result, 0, j), a);
    ActionListener Add_Action = new ActionListener() {
              public void actionPerformed (ActionEvent e)
              System.out.println ("Adding");
              ArrayList way =new ArrayList();
              way.add(new String("Uno"));
              way.add(new String("Due"));
              way.add(new String("Tre"));
              way.add(new String("Quattro"));
              myModel.addRow(new String("Nome"+i++),way,new Double(0));     
    public static void main(String[] args) {
    TableDemo frame = new TableDemo();
    frame.pack();
    frame.setVisible(true);

    In the addRow method, change the line
    this.fireTableRowsInserted(this.getRowCount(),this.getRowCount()); to
    this.fireTableRowsInserted(data.size() - 1, data.size() - 1);Sai Pullabhotla

  • Problem in reading Text file(Unicode)

    Hi
    i am trying to read a tab delimited text file which has Unicode Encoding
    try{
        BufferedReader reader = new BufferedReader(
          new InputStreamReader(
            new FileInputStream(
              "C:/Documents and Settings/divya.parkash/Desktop/Testting.txt"),
              "UTF8"));
       int buf;
       while((buf=reader.read())>-1){
        if (buf!=0)
         str.append((char)buf);
       System.out.println(str.toString());
       catch (Exception e){System.out.println("Res: "+e);}
       }but i am geting two ?? marks before the text
    ??STD_BIN HI 0  100 U10 21010100       66.550       20.000        1.000           1.200        1.200        1.300 0  100 RACKED 0 0
    STD_BIN LO 21010200  100 U10 21010200       66.550       20.000        3.000           1.200        1.200        1.300 0  100 RACKED 0 0
    STD_BIN LO 21010300  100 U10 21010300       66.550       20.000        5.000           1.200        1.200        1.300 0  100 RACKED 0 0
    STD_BIN LO 21010400  100 U10 21010400       66.550       20.000        7.000           1.200        1.200        1.300 0  100 RACKED 0 0
    STD_BIN LO 21010500  100 U10 21010500       66.550       20.000        9.000           1.200        1.200        1.300 0    0 RACKED 0 0
    STD_BIN LO 21010600  100 U10 21010600       66.550       20.000       11.000           1.200        1.200        1.300 0    0 RACKED 0 0So please suggest me the reason and solution

    Hi
    calvino_ind
    this is the output i am getting by keeping buf as int.......
    553365533838468956673789727394899494848985494895049484948494848932323232323254544653534893232323232325048464848489323232323232324946484848999932323232323232494650484893232323232323249465048489323232323232324946514848948932494848982656775696894894813108384689566737897679950494849485048489949484898549489504948494850484893232323232325454465353489323232323232504846484848932323232323232514648484899993232323232323249465048489323232323232324946504848932323232323232494651484894893249484898265677569689489481310838468956673789767995049484948514848994948489854948950494849485148489323232323232545446535348932323232323250484648484893232323232323253464848489999323232323232324946504848932323232323232494650484893232323232323249465148489489324948489826567756968948948131083846895667378976799504948494852484899494848985494895049484948524848932323232323254544653534893232323232325048464848489323232323232325546484848999932323232323232494650484893232323232323249465048489323232323232324946514848948932494848982656775696894894813108384689566737897679950494849485348489949484898549489504948494853484893232323232325454465353489323232323232504846484848932323232323232574648484899993232323232323249465048489323232323232324946504848932323232323232494651484894893232324898265677569689489481310838468956673789767995049484948544848994948489854948950494849485448489323232323232545446535348932323232323250484648484893232323232324949464848489999323232323232324946504848932323232323232494650484893232323232323249465148489489323232489826567756968948948131083846895667378976799504948494855484899494848985494895049484948554848932323232323254544653534893232323232325048464848489323232323232495146484848999932323232323232494650484893232323232323249465048489323232323232324946514848948932323248982656775696894894813108384689566737897679950494849485648489949484898549489504948494856484893232323232325454465353489323232323232504846484848932323232323249534648484899993232323232323249465048489323232323232324946504848932323232323232494651484894893232324898265677569689489481310

  • Getting the user name and computer name

    I've been trying to find out how to do this, but can't seem to get it.
    I have an AIR application that needs to get the user's login name, and computer name for verification.  I can't find anywhere to do this.  Is AIR able to get this information? Is there work arounds if there isn't?
    It won't ever be a web app, just an AIR app.

    What I did in Air 2 to accomplish that is the following:
                   public function getHostName():void {
                        if(NativeProcess.isSupported) {
                             var OS:String = Capabilities.os.toLocaleLowerCase();
                             var file:File;
                             if (OS.indexOf('win') > -1) {
                                  //Executable in windows
                                  file = new File('C:\\Windows\\System32\\hostname.exe');
                             } else if (OS.indexOf('mac') > -1 ) {
                                  //Executable in mac
                             } else if (OS.indexOf('linux')) {
                                  //Executable in linux
                             var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
                             nativeProcessStartupInfo.executable = file;
                             var process:NativeProcess = new NativeProcess();
                                  process.addEventListener(NativeProcessExitEvent.EXIT, onExitError);
                                  process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutput);
                                  process.start(nativeProcessStartupInfo);
                                  process.closeInput();
                   import utls.StringHelper;
                   public function onOutput(event:ProgressEvent):void {
                        var strHelper:StringHelper = new StringHelper();
                        var output:String = event.target.standardOutput.readUTFBytes(event.target.standardOutput.bytesAvailable);
                             output = strHelper.trimBack(output, "\n");
                             output = strHelper.trimBack(output, "\r");
                        trace('"'+output+'"');
    The package that I used is from the manual:
    package utls
         public class StringHelper
              public function StringHelper()
              public function replace(str:String, oldSubStr:String, newSubStr:String):String {
                   return str.split(oldSubStr).join(newSubStr);
              public function trim(str:String, char:String):String {
                   return trimBack(trimFront(str, char), char);
              public function trimFront(str:String, char:String):String {
                   char = stringToCharacter(char);
                   if (str.charAt(0) == char) {
                        str = trimFront(str.substring(1), char);
                   return str;
              public function trimBack(str:String, char:String):String {
                   char = stringToCharacter(char);
                   if (str.charAt(str.length - 1) == char) {
                        str = trimBack(str.substring(0, str.length - 1), char);
                   return str;
              public function stringToCharacter(str:String):String {
                   if (str.length == 1) {
                        return str;
                   return str.slice(0, 1);
    And sorry for the miss topic I just realized that it is on flex topic, but I post it either way it may be useful for anyone

  • URGENT HELP NEEDED Shmoove  !!!!!!!!!!!!!!!!!!!!!!!

    I have developed an application which has one Midlet & a .txt file(437 KB , 12276 RECORDS ) .due to large size of my text file my application is getting very slow nearly after 700 records .what should i do?
    Following is my code:
    import net.jscience.util.MathFP;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import java.lang.*;
    import java.util.*;
    import java.io.*;
    public class MyTest extends MIDlet implements CommandListener
    private Display display;     // Reference to Display object
    private Form fmMain; // Main form
    private Command cmTest; // Get contents of textfield
    private Command cmExit;          // Command to exit the MIDlet
    private Command cmStart;
    private Command cmPremium;
    private TextField tfAge; // Textfield
    private TextField tfPolicy;
    private TextField tfTerm1;
    private TextField tfTerm2;
    private TextField tfSummAss;
    String r1;
    String r2;
    String r3;
    String r4;
    String r5;
    public MyTest()
    display = Display.getDisplay(this);
    // Create commands
    cmTest = new Command("Get Contents", Command.SCREEN, 1);
    cmExit = new Command("Exit", Command.EXIT, 1);
    cmStart=new Command("Start",Command.OK,1);
    cmPremium=new Command("Premium",Command.OK,1);
         String s1 = "";
         String s2 = "";
    // Textfield for numbers entry
    tfAge = new TextField("Age:", s1, 10, TextField.ANY);
    tfPolicy = new TextField("Policy No:", s2, 10, TextField.ANY);
    tfTerm1 = new TextField("Term1:", s2, 10, TextField.ANY);
    tfTerm2 = new TextField("Term2:", s2, 10, TextField.ANY);
    // Create Form, add Commands and textfield, listen for events
    fmMain = new Form("Enter Numbers");
    fmMain.addCommand(cmExit);
    fmMain.addCommand(cmStart);
    fmMain.addCommand(cmPremium);
    fmMain.addCommand(cmTest);
    fmMain.append(tfAge);
    fmMain.append(tfPolicy);
    fmMain.append(tfTerm1);
    fmMain.append(tfTerm2);
    fmMain.setCommandListener(this);
    // Called by application manager to start the MIDlet.
    public void startApp()
         display.setCurrent(fmMain);
    public void pauseApp()
    public void destroyApp(boolean unconditional)
    public void commandAction(Command c, Displayable s)
    if (c == cmTest)
    System.out.println("TextField contains: " + tfAge.getString());
    System.out.println("MathFP Test: " +(MathFP.toString(MathFP.toFP(76))));
    else if (c == cmStart)
              r1=tfAge.getString();
              int t1 = MathFP.toFP(r1);
              System.out.println("MathFP Test1: " + (MathFP.toString(t1)));
              r2 = tfPolicy.getString();
              int t2 = MathFP.toFP(r2);
              Alert al = new Alert("YOUR PREMIUM "," YOUR PREMIUM IS = "+ MathFP.toString(t1,2), null, null);//Show the result
              al.setTimeout(Alert.FOREVER);
              al.setType(AlertType.ERROR);
              display.setCurrent(al);
         else if(c==cmPremium)
              StringBuffer buffer = new StringBuffer();
              String str[] = new String[50];
              int j=0;
              r1=tfAge.getString();
              r2=tfPolicy.getString();
              r3=tfTerm1.getString();
              r4=tfTerm2.getString();
              int t1=Integer.parseInt(r1);
              str[j]="";
              String age="";
              String table="";
              String term1="";
              String term2="";
              String premium="";
              InputStream in = this.getClass().getResourceAsStream("/manish.txt");
              try
                   int i = in.read();
                   while (i != -1 && j<11)
                        str[j]+=(char)i;
                        if(i=='\t')
                             j++;
                             str[j]="";
                             if(i=='\n')
                                  for(int k=0;k<11;k++)
                                       age = str[0].trim();
                                       table = str[1].trim();
                                       term1 = str[3].trim();
                                       term2 = str[4].trim();
                                       premium = str[5].trim();
                                  if(r1.equals(age)==true && r2.equals(table)==true && r3.equals(term1)==true && r4.equals(term2)==true)
                                       Alert box = new Alert("YOUR PREMIUM "," YOUR PREMIUM IS = "+ premium, null, null);
                                       box.setTimeout(Alert.FOREVER);
                                       box.setType(AlertType.ERROR);
                                       display.setCurrent(box);
                                       break;
                                  str[0]="";
                                  j=0;
                        i = in.read();
                   in.close();
                   catch (IOException e)
                        System.out.println(e);
    else if(c == cmExit)
    destroyApp(false);
    notifyDestroyed();

    What can I say, what you're trying to do is a heavy operation and it will slow down the phone no matter what. There are some things you can do to speed things up a little bit, but I doubt they will have a very serious effect on the speed:
    a) You are reading the InputStream one byte at a time. Try restructuring you're code to read into a byte array chunks of the stream (read(byte[] arr, int offset, int length) method).
    b) This one might be the most important. You are creating and destroying a LOT of String objects during those loops. That is creating a LOT of garbage and I imagine the garbage collector starts working overtime (after 700 records like you said), and seriously slowing you down. Try changing that code into using only StringBuffers instead of Strings (and make you're StringBuffers large enough), so that less garbage is created.
    Other than that, I don't know if you're targetting any specific device, but a most of the current devices (except for a few high-end devices) won't have enough heap memory to handle so much data. Not to mention jar size constraints. So it might not be realistic to hope that the phone handle that processing. If it's possible, what I would do is offload all of that premium calculating to a server and use http to get the result from it.
    shmoove

  • I/O Problems

    First off, here's the code. It's a simple socket client that I want to talk to my server client. I would love for this to end up being more like a telnet type application.
    import java.io.*;
    import java.net.*;
    public class Wire
         public static void main(String[] args)
              String host;
              System.out.println("Beginning main process");
              if (args.length > 0)
                   host =(args[0]);
                   System.out.println("Host: " +host);
              else
                   host = "localhost";
                   System.out.println("No host set, setting host to localhost");
              int port;
              if (args.length > 1)
                   port = Integer.parseInt(args[1]);
                   System.out.println("Port: " +port);
              else
                   port = 7337;
                   System.out.println("No port set, setting port to 7337");
              int timeout = 10000;
              System.out.println("Setting timeout to 10 seconds");
              Socket s = WireThread.openSocket(host, port, timeout);
              if (s == null)
                   System.out.println("The socket could not be opened.");
              else
              System.out.println("Connected to:");
                   System.out.println(s);
              try
                   s.close();
              catch (Exception e)
                   System.out.println(e);
    class WireThread implements Runnable
         InputStreamReader isr = null;
    BufferedReader in = null;
    PrintWriter out = null;
         StringBuffer str = null;
         public static Socket openSocket(String aHost, int aPort, int timeout)
         WireThread wirethread = new WireThread(aHost, aPort);
         Thread t = new Thread(wirethread);
         System.out.println("Starting client thread");
         t.start();
         try
         System.out.println("Join method");
         t.join(timeout);
         catch (InterruptedException exception)
              System.out.println("Interrupted Exception");
         return wirethread.getSocket();
         public WireThread(String aHost, int aPort)
         System.out.println("Setting WireThread variables");
         socket = null;
         host = aHost;
         port = aPort;
         public void run()
         System.out.println("Setting client socket");
         try
         socket = new Socket(host, port);
         catch (IOException exception)
              System.out.println("I/0 Exception");
    try
              isr = new InputStreamReader(socket.getInputStream());
    in = new BufferedReader(isr);
    out = new PrintWriter(socket.getOutputStream(),true);
              StringBuffer str = new StringBuffer(128);
              String inStr;
              int c;
              String prop = System.out.getProperties(prop);
              System.out.println(prop);
              while ((inStr = in.readLine()) != null)
                   System.out.println(inStr);
                   while ((c = System.in.read()) != '/n')
                        str.append((char)c);
              System.out.println("Client: " + str);
                   out.println(str.toString());
                   out.flush();
                   if (str.equalsIgnoreCase("exit"))
                   in.close;
                        out.close;
                        break;
                   str.setLength(0);
         catch (IOException e)
              System.err.println("I/O error: " +e.toString());
         public Socket getSocket()
         System.out.println("Getting remote server socket");
         return socket;
         private String host;
         private int port;
         private Socket socket;
    The problem is, my current implentation of "exit" is not working at all. I get errors on compile right now, but in my previous try, it compiled ok, but it didn't matter if I typed exit, or another command, it still did the same thing, which was create an I/O Exception, and close. I can't get it to close cleanly. The server is supposed to take the argument "exit" and close. I'm also having problems working with the string buffer. How can I convert it to a string and actually have a string object so that I can do stuff like = and != on it? Does someone see what my problem is?

    Here's a few things that will be compile errors:String prop = System.out.getProperties(prop); // should be System.getProperty("something")?
    while ((c = System.in.read()) != '/n') // should be '\n'
    in.close; // should be close()
    out.close;  // should be close()There may be more. Also, you'd find it easier to read a line from the console if you wrapped a BufferedReader around System.in, just as you did for your socket input. Sorry I can't find the logic problem.

  • Help with GUI program

    Writing a program that uses menu options of ADD, SUBTRACT, MULTIPLY, and DIVIDE.
    The user enters a number in a field labeled "Number 1" then enters a number in a field labeled "Number 2". The final field is labeled "Result"
    Each of the menu options has an ActionEvent.
    I'm having trouble with how to get the fields for Number 1 and Number 2 to display in the Result field when the user selects one of the menu options.
    Here is the code with an ActionEvent started for "Add" but not finished since I neeed some advice from this point on....
    Please disregard the other menu options, at this point I am just working on the math portion...
    Cheers!
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Brown7 extends JFrame implements ActionListener
    public static final int WIDTH = 400;
    public static final int HEIGHT = 200;
    private JTextField inputField, inputsecondField, resultField;
    private double sum = 0;
    private double difference = 0;
    private double product = 0;
    private double quotient = 0;
    public Brown7()
    setSize (WIDTH, HEIGHT);
    addWindowListener(new WindowDestroyer());
    setTitle ("Menu Demo");
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout());
    JButton sumbutton = new JButton("Add");
    sumbutton.addActionListener(this);
    buttonPanel.add(sumbutton);
    JButton subbutton = new JButton("Subtraction");
    subbutton.addActionListener(this);
    buttonPanel.add(subbutton);
    JButton multbutton = new JButton("Multiply");
    multbutton.addActionListener(this);
    buttonPanel.add(multbutton);
    JButton divbutton = new JButton("Divide");
    divbutton.addActionListener(this);
    buttonPanel.add(divbutton);
    contentPane.add(buttonPanel, BorderLayout.SOUTH);
    JPanel infoPanel = new JPanel();
    infoPanel.setLayout(new FlowLayout());
    JLabel nameLabel = new JLabel("Number 1");
    infoPanel.add(nameLabel);
    inputField = new JTextField("", 3);
    infoPanel.add(inputField);
    JLabel secondnameLabel = new JLabel("Number 2");
    infoPanel.add(secondnameLabel);
    inputsecondField = new JTextField("", 3);
    infoPanel.add(inputsecondField);
    JLabel resultLabel = new JLabel("Result");
    infoPanel.add(resultLabel);
    resultField = new JTextField("", 5);
    infoPanel.add(resultField);
    contentPane.add(infoPanel);
    JMenuBar mBar = new JMenuBar();
    setJMenuBar(mBar);
    JMenu operationsMenu = new JMenu("Operations");
    mBar.add(operationsMenu);
    JMenuItem o;
    o = new JMenuItem("Add");
    o.addActionListener(this);
    operationsMenu.add(o);
    o = new JMenuItem("Subtract");
    o.addActionListener(this);
    operationsMenu.add(o);
    o = new JMenuItem("Multiply");
    o.addActionListener(this);
    operationsMenu.add(o);
    o = new JMenuItem("Divide");
    o.addActionListener(this);
    operationsMenu.add(o);
    JMenu viewMenu = new JMenu("View");
    mBar.add(viewMenu);
    JMenuItem v;
    v = new JMenuItem("Metal");
    v.addActionListener(this);
    viewMenu.add(v);
    v = new JMenuItem("Motif");
    v.addActionListener(this);
    viewMenu.add(v);
    v = new JMenuItem("Windows");
    v.addActionListener(this);
    viewMenu.add(v);
    JMenu exitMenu = new JMenu("Exit");
    mBar.add(exitMenu);
    JMenuItem e;
    e = new JMenuItem("Close");
    e.addActionListener(this);
    exitMenu.add(e);
    public void actionPerformed(ActionEvent e)
    if (e.getActionCommand().equals("Close"))
    System.exit(0);
    else if (e.getActionCommand().equals("Add"))
    else
    System.out.println("Error in Brown7 interface.");
    public static void main(String[] args)
    Brown7 gui = new Brown7();
    gui.setVisible(true);

    You can use a JOptionPane for the textfield input. Here I used a DocumentFilter (new in JDK1.4). It allows only specified characters to be entered and beeps for illegal characters. If you still want a message dialog you can add it in the document filter class with (or in place of) the Toolkit..beep call.
    I also changed the variable result to a double and added a NumberFormat to allow formatting to only one decimal place for fractions (as a result of division) in resultField.
    I gave a choice of YES_NO vs. YES_NO_CANCEL options in the exit dialog.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.text.NumberFormat;    // new
    import javax.swing.text.*;        // new
    public class BrownTest extends JFrame implements ActionListener
        public static final int WIDTH = 400;
        public static final int HEIGHT = 200;
        private JTextField inputField, inputsecondField, resultField;
        private double sum = 0;
        private double difference = 0;
        private double product = 0;
        private double quotient = 0;
        NumberFormat nf;
        JFrame frame = this;
        public BrownTest()
            nf = NumberFormat.getInstance();
            nf.setMaximumFractionDigits(1);
            setSize (WIDTH, HEIGHT);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            setTitle ("Menu Demo");
            Container contentPane = getContentPane();
            contentPane.setLayout(new BorderLayout());
            JPanel buttonPanel = new JPanel();
            buttonPanel.setLayout(new FlowLayout());
            JButton sumbutton = new JButton("Add");
            sumbutton.addActionListener(this);
            buttonPanel.add(sumbutton);
            JButton subbutton = new JButton("Subtract");
            subbutton.addActionListener(this);
            buttonPanel.add(subbutton);
            JButton multbutton = new JButton("Multiply");
            multbutton.addActionListener(this);
            buttonPanel.add(multbutton);
            JButton divbutton = new JButton("Divide");
            divbutton.addActionListener(this);
            buttonPanel.add(divbutton);
            contentPane.add(buttonPanel, BorderLayout.SOUTH);
            JPanel infoPanel = new JPanel();
            infoPanel.setLayout(new FlowLayout());
            JLabel nameLabel = new JLabel("Number 1");
            infoPanel.add(nameLabel);
            inputField = new JTextField("", 3);
            infoPanel.add(inputField);
            JLabel secondnameLabel = new JLabel("Number 2");
            infoPanel.add(secondnameLabel);
            inputsecondField = new JTextField("", 3);
            infoPanel.add(inputsecondField);
            JLabel resultLabel = new JLabel("Result");
            infoPanel.add(resultLabel);
            resultField = new JTextField("", 5);
            infoPanel.add(resultField);
            // set document filter on textfield documents
            String integerDomain = "-.0123456789";
            FieldNumberFilter filter = new FieldNumberFilter(integerDomain);
            AbstractDocument doc = (AbstractDocument)inputField.getDocument();
            doc.setDocumentFilter(filter);
            doc = (AbstractDocument)inputsecondField.getDocument();
            doc.setDocumentFilter(filter);
            doc = (AbstractDocument)resultField.getDocument();
            doc.setDocumentFilter(filter);
            contentPane.add(infoPanel);
            JMenuBar mBar = new JMenuBar();
            setJMenuBar(mBar);
            JMenu operationsMenu = new JMenu("Operations");
            mBar.add(operationsMenu);
            JMenuItem o;
            o = new JMenuItem("Add");
            o.addActionListener(this);
            operationsMenu.add(o);
            o = new JMenuItem("Subtract");
            o.addActionListener(this);
            operationsMenu.add(o);
            o = new JMenuItem("Multiply");
            o.addActionListener(this);
            operationsMenu.add(o);
            o = new JMenuItem("Divide");
            o.addActionListener(this);
            operationsMenu.add(o);
            JMenu viewMenu = new JMenu("View");
            mBar.add(viewMenu);
            ViewMenuListener viewMenuListener = new ViewMenuListener();
            JMenuItem v;
            v = new JMenuItem("Metal");
            v.addActionListener(viewMenuListener);
            viewMenu.add(v);
            v = new JMenuItem("Motif");
            v.addActionListener(viewMenuListener);
            viewMenu.add(v);
            v = new JMenuItem("Windows");
            v.addActionListener(viewMenuListener);
            viewMenu.add(v);
            JMenu exitMenu = new JMenu("Exit");
            mBar.add(exitMenu);
            JMenuItem e;
            e = new JMenuItem("Close");
            e.addActionListener(this);
            exitMenu.add(e);
         * Listener for the Operations and Close menu items
        public void actionPerformed(ActionEvent e)
            String ac = e.getActionCommand();
            if (ac.equals("Close"))
                String message = "Are you sure you want to exit this program?";
                int returnVal = JOptionPane.showConfirmDialog(frame,
                                                              message,
                                                              "Exit Dialog",
                // either this */                             JOptionPane.YES_NO_OPTION,
                /* or this */                                 JOptionPane.YES_NO_CANCEL_OPTION,
                                                              JOptionPane.QUESTION_MESSAGE);
                if(returnVal == JOptionPane.CANCEL_OPTION ||
                   returnVal == JOptionPane.CLOSED_OPTION)
                    return;
                if(returnVal == JOptionPane.YES_OPTION)
                    System.exit(0);
                if(returnVal == JOptionPane.NO_OPTION);
                    frame.dispose();
            // read entered data
            String one = inputField.getText();
            String two = inputsecondField.getText();
            // if no entry, return
            if(one.equals("") || two.equals(""))
                return;
            // attempt to parse data
            double first, second;
            try
                first  = Double.parseDouble(one);
                second = Double.parseDouble(two);
            catch(NumberFormatException nfe)
                System.out.println(nfe.getMessage());
                return;
            // now we have good data, do calculations
            double result = 0;
            if (ac.equals("Add"))
                result = first + second;
            else if(ac.equals("Subtract"))
                result = first - second;
            else if(ac.equals("Multiply"))
                result = first * second;
            else if(ac.equals("Divide"))
                result = first / second;
            else
                System.out.println("Error in Brown7 interface.");
            resultField.setText(nf.format(result));
         * Listener for the View menu items
        private class ViewMenuListener implements ActionListener
            UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels();
            public void actionPerformed(ActionEvent e)
                JMenuItem item = (JMenuItem)e.getSource();
                String ac = item.getActionCommand();
                String name = null;
                for(int i = 0; i < info.length; i++)
                    if(info.getName().indexOf(ac) != -1)
    name = info[i].getClassName();
    if(name == null)
    return;
    try
    UIManager.setLookAndFeel(name);
    catch(ClassNotFoundException cnfe)
    System.out.println(cnfe.getMessage());
    catch(InstantiationException ie)
    System.out.println(ie.getMessage());
    catch(IllegalAccessException iae)
    System.out.println(iae.getMessage());
    catch(UnsupportedLookAndFeelException ulafe)
    System.out.println(ulafe.getMessage());
    SwingUtilities.updateComponentTreeUI(BrownTest.this);
    public static void main(String[] args)
    BrownTest gui = new BrownTest();
    gui.setVisible(true);
    * Document filter for input validation in textfields
    class FieldNumberFilter extends DocumentFilter
    String allowables;
    public FieldNumberFilter(String legalCharacters) {
    allowables = legalCharacters;
    public void insertString(DocumentFilter.FilterBypass fb,
    int offset,
    String str,
    AttributeSet attr) throws BadLocationException {
    replace(fb, offset, 0, str, attr);
    public void replace(DocumentFilter.FilterBypass fb,
    int offset,
    int length,
    String str,
    AttributeSet attrs) throws BadLocationException {
    char[] source = str.toCharArray();
    char[] result = new char[source.length];
    int j = 0;
    for(int i = 0; i < result.length; i++)
    if(allowables.indexOf(source[i]) != -1)
    result[j++] = source[i];
    else
    Toolkit.getDefaultToolkit().beep();
    fb.replace(offset, length, new String(result, 0, j), attrs);

  • How to handle a comma in a field in CSV file during FCC ?

    Hi,
    I am having a requirement where we have to convert a CSV file into XML using File Content Conversion . The issue is one of the field in the file is having a comma inside. So the XML parser is taking it as a field separator and throwing an error.
    The contents of the file are as follows:
    "02975859","New Key","9","Failed, rejected by RTI server"
    How to handle a comma inside field "Failed, rejected by RTI server".
    Any help would be appreciated.
    Regards
    Pravesh

    Hi ,
    You have to write an java mapping programm to perdromance this task , in a estandar way i think is not possible , because the fiel adapter have just one option for the delimiter character.
    Here's some code that could help you
    Supouse a file in this way:
    1,rahul,siemens,mumbai
    2,consultant,12032005
    1,viswanath,sisl,hyderabad
    2,systemeng,23052005
    package TXTMapping;
    import java.io.BufferedReader;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.util.Map;
    import com.sap.aii.mapping.api.StreamTransformation;
    public class TMapping implements StreamTransformation {
    private Map map;
    public void setParameter (Map param){
    map = param;
    public void execute (InputStream in, OutputStream out){
    try{
    out.write("<?xml version ='1.0' encoding='UTF-8'?>".getBytes());
    out.write("<ns0:Output_Data xmlns:ns0=\"urn:javamapping_test\">".getBytes());
    String line = null;
    BufferedReader bin = new BufferedReader(new InputStreamReader(in));
    StringBuffer buffer = new StringBuffer();
    while((line = bin.readLine())!= null){
    String Company = null;
    String Name = null;
    String Place = null;
    String Desgn = null;
    String Since = null;
    char[] str= new char[100];
    str = line.toCharArray();
    String[] Data = new String[10];
    int S1 = 0;
    int s2 = 2;
    for (int i=2; i<line.length(); i++)
    if (str<i>==',' && str[0]=='1')
    Data[S1]= line.substring(s2,i);
    S1=S1+1;
    s2 = i+1;
    if (i == line.length()-1 && str[0] == '1')
    Data[S1]= line.substring(s2,i+1);
    Name = Data[0];
    Company = Data[1];
    Place = Data[2];
    out.write ("<Data>".getBytes());
    out.write ("<Header>".getBytes());
    out.write (("<Name>"Name"</Name>").getBytes());
    out.write (("<Company>"Company"</Company>").getBytes());
    out.write (("<Place>"Place"</Place>").getBytes());
    out.write ("</Header>".getBytes());
    if (str<i>==',' && str[0]=='2')
    Data[S1]= line.substring(s2,i);
    S1=S1+1;
    s2 = i+1;
    if (i == line.length()-1 && str[0] == '2')
    Data[S1]= line.substring(s2,i+1);
    Desgn = Data[0];
    Since = Data[1];
    out.write ("<Item>".getBytes());
    out.write (("<Designation>"Desgn"</Designation>").getBytes());
    out.write (("<Since>"Since"</Since>").getBytes());
    out.write ("</Item>".getBytes());
    out.write ("</Data>".getBytes());
    out.write("</ns0:Output_Data>".getBytes());
    catch(Throwable t){
    t.printStackTrace();

  • I need to make a spreadsheet based on info from specific table columns and headlines above those tab

    Hi all,
    A client of mine is requesting that I create a spreadsheet from a huge catalog that I am doing for him (this will also be done for all similar huge catalogs). The spreadsheet needs to pull information from some of the table columns, as well as the headline for each table. (This spreadsheet will then go out to some other people who will be putting this information into an online database/website for the client.) Let me be more specific and show you an example below.
    Information from InDesign Catalog:
    Tea Set
    Part #
    MFG #
    Description
    123-456
    654321
    Tea Cup
    789-010
    010987
    Saucer
    Here is how the Excel Spreadsheet needs to look:
    Part #
    MFG #
    Product Name
    Description
    Page #
    123-456
    654321
    Tea Set
    Tea Cup
    2
    789-010
    010987
    Tea Set
    Saucer
    2
    You have no idea how I have been pulling my hair out over this. Doing this manually will be a nightmare each time. My first thought was that I could assign specific cell styles to the columns (cells) and then create a TOC and then finangle with that - well, that didn't quite work, especially because of the headline I needed to pull into the spreadsheet as well. Is there ANY way I can get this information onto a spreadsheet? Knowing how wonderful InDesign is and all the tremendous capability it has, I am sure there IS a way and I just dont know how. Please PLEASE can someone point me in the right direction?
    Thank you very much in advance for your assistance:) Any help would be greatly appreciated.
    Christine

    Sorry for the delay.
    I am sure that this can somehow be done by making use of the styles. For example, when creating the TOC InDesign does a GREAT job of pulling in the styles (that are of course associated with the headlines and whatever needs to be included in the TOC) and associating them with the correct page numbers. I had experimented a little with creating specific paragraph styles and working these into the table and cell styles...then applying the Table Style to the table. I was halfway getting to where I wanted to be by creating a TOC that pulled in all of these styles and applied the corresponding page numbers (that I could somehow work into converting back into a table to then flow onto an Excel spreadsheet) but the wrench in the works was of course the Product Name. That said, I am VERY confident that this CAN be done somehow, by making use of the styles, using the same (or similar) methodology that is used to create the TOC. If only I were a pro at scripting...
    Well, it's great that you're certain and confident, but I think your confidence is misplaced.
    I had sort of hoped that running headers could be convinced to support this, but that doesn't seem to be true.
    I think you need to postprocess the data somehow. If I was doing this for real I'd probably export the document to IDML and have a seperate program read the IDML XML, find the product names and page numbers, and insert them in tables. Though...that might mess up the page numbers. And it'd be a lot of work.
    An much-faster-to-rapid-prototype solution is to have an indesign script go through the document and add in page numbers and the product names. Here's a rough prototype:
    var d,s,story,table,product,page,c2,c3,c5,i,j.k;
    d=app.activeDocument;
    s=d.stories;
    for (i=0; i<s.length; i++) {
        story = s[i];
        for (j=0; j<story.tables.length; j++) {
            table = story.tables[j];
            product = story.chara
    cters[table.storyOffset.index-2].paragraphs[0].contents;
            page = table.parent.parentPage.name;
            // $.writeln("This is table "+j+". Product name: "+product+" page "+page);
            c2=table.columns[1];
            c3=table.rows[0].columns.add(LocationOptions.AFTER, c2);
            c3.contents=product;
            c5=table.rows[0].columns.add();
            c5.contents=page;
    This doesn't handle the header rows in tables, but hopefully that's ok.
    It may get page numbers wrong on multipage tables. Probably it would be better to just use
    SpecialCharacters.AUTO_PAGE_NUMBER on the last full line (c5.contents=).
    It should also probably not just look back 2 characters from the start of the table to find the paragraph, but it's probably good enough.

Maybe you are looking for