riahc3 50 Â Team Colleague

Any way on how to do it?

riahc3 50 Â Team Colleague

....did this thread move?

riahc3 50 Â Team Colleague

Check the PHP forum, there are enough threads about uploading files.

I perfer doing this with jQuery or something...

riahc3 50 Â Team Colleague
print_r($_POST);

Prints out:

Array ( )

riahc3 50 Â Team Colleague

Same error.

riahc3 50 Â Team Colleague

For both lines

riahc3 50 Â Team Colleague

OK got something semiworking......

(Itll do for now from the computer its on and attached network computers)

HTML:

<form id="form1input" action="page.php" method="post" enctype="multipart/form-data">
    <h3>File:</h3>
    <input id="file" type="file" name="file" /><br/>
    <input id="submit" type="submit" value="Upload File"/>
    </form>

PHP:

<?php



                $name=$_POST["file"];
                echo ($name);

                echo ($_POST["file"]);
                exit;

Says undefinded index file.....

riahc3 50 Â Team Colleague

Cant seem to get your standard textbox and a button aside that says "Browse" working....

riahc3 50 Â Team Colleague

undeploy/deploy does not completely free up all memory your app used. Restart the server will be necessary sometimes.

also you can see following for your knowledge.

Anyway I can make it huge to further reduce the chance of having to restart the server?

riahc3 50 Â Team Colleague

Hello

Lets say I have a text file, in a local or remote location. I want to select it with a file picker (standard Windows browser seleccion). Once I have that selected, I want to click a send button. This send will download the text file from whereever it is at then FTP it over to a server. After that, I want to call a web service.

Lets start from scratch. What is the best way to do the selecting the file from anywhere? From anywhere I mean a Windows shared computer but it should be able to get from another FTP location.

Thank you

riahc3 50 Â Team Colleague

Hello

Sometimes I update my web service JAR by deleting the old one (waiting for the undeploy message to appear on the console) and putting the new one (and seeing the deploy message) and when I call it, it gives a heap size error. I have to restart the PC and from then on, it works perfectly 9999999999 times over when I call it.

Why is this? How can I avoid it?

riahc3 50 Â Team Colleague

OK, Im seeing a comment saying "There should be no change to the pointer we were passed"

Im THINKING you are passing code from C to Java.

So the issue with this is a that in C there are no objects while in Java there is so you have to sort of change the orientation and method of programming.

But first lets confirm that: Are you porting C code to Java?

riahc3 50 Â Team Colleague

A Android app..........Hmm...............

Porting my crude example to Android would only have the problem of the Jersey library AFAIK.

riahc3 50 Â Team Colleague

Do we have any decent app that uses the API yet?

Like I said, my own posting app would be intresting but I havent had any time to develop it.

riahc3 50 Â Team Colleague

Exactly. I knew I did one in the crappiest language known to mankind:

http://www.daniweb.com/software-development/java/code/448125/java-and-daniwebs-api-example-nasty-simple-and-quick-code

Crude and nasty example. I dont plan to further develop it either (unless its a quick and easy fix)

riahc3 50 Â Team Colleague

Waiting for the java version of the API...When can i expect a java version?

I know I posted a C# example; Did I do a Java one as well?

riahc3 50 Â Team Colleague

I believe the site legally has to allow a option to delete all information (personal).

riahc3 50 Â Team Colleague

Hello

Today in a thread, I wrote shit and it was not censored at that moment.

And I just made this thread and it is not censored.

Why?

riahc3 50 Â Team Colleague

Thought I marked it as solve.

Yes, Im trying to get a cert that has nothing to do with programming (Computers, but not programming)

riahc3 50 Â Team Colleague

Anyways thats it. Thank you JamesCherrill as you are the only one that truely helped.

Also, I deal almost on a daily base with PHP, JS, C#, Java, shell scripting.....and on top of that I hate programing so these elementary mistakes slip me.

riahc3 50 Â Team Colleague

What did you do with the String that the format method returns? I KNOW you are a better Java programmmer than this.

Another reason why Java is ****; I thought It automatically changed it (which would be logic but then again Java isnt logic...), it wasnt suppose to return another String....

riahc3 50 Â Team Colleague

Also, if you basically told me what is the elementary mistake in the code, this thread would end. I got the symbol, the decimal thing working.......pretty much nothing else to do except display two decimal positions always.

riahc3 50 Â Team Colleague

I'm worried. This thread has become very unheathy - just look at the number and kind of questions that are being asked. I know you have the Java skills to answer many of them yourself, and I don't think I'm providing the right kind of help any more.

So this may br my last post in the thread (maybe)...
Yes. Answered. What makes you think that that code will do anything other than print result (a double) in a system default format?
If you don't know how to use a NumberFormat then read the API doc, read the examples, Google if necessary. Don't just guess. The mistake in your code is a very elementary one.

......ooooooooooooo............kkkkkkkkkkk............."Unhealthy"?

Anyways, I looked up that NumberFormat and saw how it works. http://www.avajava.com/tutorials/lessons/how-do-i-use-numberformat-to-format-doubles.html?page=1

As far as I can see, it is set up correctly.

Java's API has always been basically a cat that has been ran over by a truck on a highway: Dead crap. Looked it up anyways and it basically told me nothing that example page didnt tell me and explained it better.

riahc3 50 Â Team Colleague

Already answered (17 hours ago).

double result=Double.valueOf(price)*Double.valueOf(String.valueOf(multiply)); //I store it as a float for decimal reasons
        NumberFormat nb=NumberFormat.getInstance();
        nb.setMinimumFractionDigits(2);
        nb.setMaximumFractionDigits(2);
        nb.format(result);
        System.out.println(result);

Nope, not answered. Still shows without 2 digits to the right of the decimal point.

riahc3 50 Â Team Colleague

So whats the best way to make sure those two decimal points appear?

riahc3 50 Â Team Colleague

What is the best way to do this?

Annoying when you have been stuck almost a day and something...

riahc3 50 Â Team Colleague

It may or may not be. I just want 2 decimal places to the righrt.

riahc3 50 Â Team Colleague

Yes, basically. 2 digits to the right of the decimal point, infinite to its left.

riahc3 50 Â Team Colleague

Got it. The only thing is that I want it to be stored as 32,00 instead of 32,0

riahc3 50 Â Team Colleague

Seriously - time for a break. Trust me!

Im on my break :P

Pretty much nothing to do except figure out how to do this and move on with the next thing (which I cant do without solving this)......

riahc3 50 Â Team Colleague

Fucking incredible

        String price="16,00 €"; //Price
        int multiply=2; //Multiplcation that I want to do to price
        int positions=0; //Position of the symbol
        int positiond=0; //Position of the decimal
        char[] symbols = new char[] { '€','$' }; //Symbols that are avaliable
        char[] decimalseperators= new char[] { '.',',' }; // Decimal markers that are avaliable
        char symbol=' '; //Somewhere to store the symbol
        char deci=' '; //Somewhere to store the decimal
        String blank="";
        boolean pre; //Check if the decimal is before or after the the symbol




        for (int i=0;i<decimalseperators.length;i++) //I run thru the entire decimal array and the price itself to look for the decimal
        {
            deci=decimalseperators[i];
            if (price.indexOf(deci)  >=0)
            {
                if (deci!='.') //If the decimal is not a dot, for compatibility reasons, I change it to a dot
                {

                    StringBuilder newprice = new StringBuilder(price);
                    newprice.setCharAt(price.indexOf(deci), '.');
                    price=newprice.toString();
                }
                positiond=price.indexOf(deci); //I store the position of the decimal point
                break;
            }

        }

        for (int i=0;i<symbols.length;i++) //I run thru the entire symbol array and the price itself to look for the symbol
        {
            symbol=symbols[i];
             if (price.indexOf(symbol) >= 0) 
             {
                 char[] charprice=price.toCharArray();
                 StringBuilder sb = new StringBuilder();
                 sb.append(charprice);
                 sb.deleteCharAt(price.indexOf(symbol));
                 charprice = sb.toString().toCharArray();
                 price=charprice.toString();             



                 positions=price.indexOf(symbol); //I store the position of the symbol
                 break;
             }
        }

        if (positions >positiond) //If symbol after the decimal
         {
             pre=false;

         }
        else //If the symbol is before the decimal
        {
            pre=true;
        }
        float result=Float.valueOf(price)*Float.valueOf(String.valueOf(multiply)); //I store it as a float for decimal reasons



        if (pre==false) //Put it all together again
        {
            price=result+" "+symbol;
        }
        else
        {
            price=symbol+" "+result;
        } …
riahc3 50 Â Team Colleague
char[] charprice=price.toCharArray();
charprice[price.indexOf(symbol)]='';

This and so many reasons is why Java sucks. Why doesnt this work?

riahc3 50 Â Team Colleague

There are loads of ways to do this using standard methods from the String class, or char arrays, or regular expressions (etc). I'm not going to deprive you of the pleasure of finding one for yourself ;)

Iv obviously used the String class (where would I get the parse float function) so I dont see much other functions that can do this
I dont think going from String to a char array removing it and then stringing it again, is the best way to do this but if there is no other way, what choice do I have
Im not into regular expressions.

riahc3 50 Â Team Colleague

Possibly the worst advice of 2013 so far in this forum. Even if you never write a single program for real, even your teacher will read and mark your code. Coding standards and conventions are there to help everybody, and the sooner you engrain all the right habits the better.

I disagree.

If noone is going to read your code, name things however you feel like that makes sense to you and you remember it. This of course if only YOU are going to read the code.

I shouldnt prepare my code for others.

One of the most important things when coding is commenting; Commenting is more for you than others as you maybe one day see your code again and say "Why did I do that?". It makes life so much easier.

But other than that? If you want to name two int variables HiIAmBerry and another one klshldgfkjhsgfdj and add them up to a ohrlylolo varaible, be my guest! As long as you comment them and later remember why/what they do

riahc3 50 Â Team Colleague

Because your currency symbol ould be anything you will have to remove it yourself.

How can I remove everything except numbers? (Yes, I know Ill have to switch the orders of the fors)

riahc3 50 Â Team Colleague

And about the jar/exe thing.........I THOUGHT a jar was made when you ran but you have to change some setting. Ill look it up.

riahc3 50 Â Team Colleague

I ment that if you want to call it Play, call it Play. If you want to call itkljsdgkjhdskjg, call it that. Whatever is clearest to you...

riahc3 50 Â Team Colleague

I have to remove the symbol.......

parseFloat should do it but....

riahc3 50 Â Team Colleague

Have you uninstalled and reinstalled Eclipse?

riahc3 50 Â Team Colleague

Do not use any built-in date functions in your computer language.

What? Why reinvent the wheel?

riahc3 50 Â Team Colleague

We need more than that. Pretty much tells us nothing.

What is "Tree_Node"?

riahc3 50 Â Team Colleague

Thank you for the quick response bguild. That was carelessness on my part about the Play method naming.

Personally, dont listen to bguild; In most cases, noone sees your code except you. You dont need to write how a set of code conventions state. You write the code however it is clearest/makes sense to you. First, write the code how it is clearest to you, the developer. THEN do things to better the code, optimize, etc.

I think a precomplied jar/exe would have been nice to test your program out...Was your program free choosing (you choose to do this) or assigned?

riahc3 50 Â Team Colleague
String price="16,00 €"; //Price
        int multiply=2; //Multiplcation that I want to do to price
        int positions=0; //Position of the symbol
        int positiond=0; //Position of the decimal
        char[] symbols = new char[] { '€','$' }; //Symbols that are avaliable
        char[] decimalseperators= new char[] { '.',',' }; // Decimal markers that are avaliable
        char symbol=' '; //Somewhere to store the symbol
        char deci=' '; //Somewhere to store the decimal
        boolean pre; //Check if the decimal is before or after the the symbol

        for (int i=0;i<symbols.length;i++) //I run thru the entire symbol array and the price itself to look for the symbol
        {
            symbol=symbols[i];
             if (price.indexOf(symbol) >= 0) 
             {
                 positions=price.indexOf(symbol); //I store the position of the symbol
                 break;
             }
        }
        for (int i=0;i<decimalseperators.length;i++) //I run thru the entire decimal array and the price itself to look for the decimal
        {
            deci=decimalseperators[i];
            if (price.indexOf(deci)  >=0)
            {
                if (deci!='.') //If the decimal is not a dot, for compatibility reasons, I change it to a dot
                {
                    StringBuilder newprice = new StringBuilder(price);
                    newprice.setCharAt(price.indexOf(deci), '.');
                    price=newprice.toString();
                }
                positiond=price.indexOf(deci); //I store the position of the decimal point
                break;
            }

        }

        if (positions >positiond) //If symbol after the decimal
         {
             pre=false;

         }
        else //If the symbol is before the decimal
        {
            pre=true;
        }
        float result=Float.parseFloat(price)*Float.parseFloat(String.valueOf(multiply)); //I store it as a float for decimal reasons

        if (pre==false) //Put it all together again
        {
            price=result+" "+symbol;
        }
        else
        {
            price=symbol+" "+result;
        }

        System.out.println(price); //Print it out
        System.exit(1);

Here it is. Gives me a error on the result line with …

riahc3 50 Â Team Colleague

what you are writing seems to me more a mix between pseudo code and actual code.

I felt the exact same thing.

riahc3 50 Â Team Colleague

Hmmmm cant seem to get it to work.

Must be a focus issue.

riahc3 50 Â Team Colleague
String price="16,00 €";
        int positions;
        int positiond;
        char[] symbols = new char[] { '€','$' };
        char[] decimalseperators= new char[] { '.',',' };
        char symbol=' ';
        char deci=' ';
        boolean pre;
        for (int i=0;i<symbols.length;i++)
        {
            symbol=symbols[i];
             if (price.indexOf(symbol) >= 0) 
             {
                 positions=price.indexOf(symbol);
                 break;
             }
        }
        for (int i=0;i<decimalseperators.length;i++)
        {
            deci=decimalseperators[i];
            if (price.indexOf(deci)  >=0)
            {
                positiond=price.indexOf(deci);
                break;
            }

        }

        if (positions >positiond)
         {
             pre=false;

         }
        else
        {
            pre=true;
        }

This should work.

riahc3 50 Â Team Colleague

pre is a variable if its prefixed (true) or postfixed (false)

riahc3 50 Â Team Colleague
String price="16,00 €";
        int position;
        char[] symbols = new char[] { '€','$' };
        char[] decimalseperators= new char[] { '.',',' };
        char symbol=' ';
        char deci=' ';
        boolean pre;
        for (int i=0;i<symbols.length;i++)
        {
            symbol=symbols[i];
             if (price.indexOf(symbol) >= 0) //this is the right symbol...
             {
                 position=price.indexOf(symbol);
                 break;
             }
        }
        for (int i=0;i<decimalseperators.length;i++)
        {
            deci=decimalseperators[i];
            if (price.indexOf(position)  < price.indexOf(deci))
            {
                pre=true;
            }
            else
            {
                pre=false;
            }
        }

This looks pretty good and logic.

riahc3 50 Â Team Colleague

So how do I do the keypresses that call the action that is the click on those buttons?

Pressing 3 on my keyboard launches the event of pressing the "3" button.

riahc3 50 Â Team Colleague
package CalculatorGUI;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import javax.swing.JLabel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class CalulatorGUI extends JFrame implements KeyListener {



    private JPanel contentPane;

    JPanel panel = new JPanel();


    JButton button1 = new JButton("1");


    JButton button4 = new JButton("4");


    JButton button7 = new JButton("7");


    JButton button2 = new JButton("2");


    JButton button5 = new JButton("5");


    JButton button8 = new JButton("8");


    JButton button3 = new JButton("3");


    JButton button6 = new JButton("6");


    JButton button9 = new JButton("9");


    JButton button0 = new JButton("0");


    JButton buttonplus = new JButton("+");


    JButton buttonminus = new JButton("-");


    JButton buttontimes = new JButton("*");


    JButton buttondivide = new JButton("/");


    JLabel labelinout = new JLabel("");


    JButton buttonequal = new JButton("=");
    private final JButton buttonclear = new JButton("CLEAR");
    private final JButton buttondot = new JButton(".");
    private final JButton buttonopen = new JButton("(");
    private final JButton buttonclose = new JButton(")");





    public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
        } catch (ClassNotFoundException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (InstantiationException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (IllegalAccessException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (UnsupportedLookAndFeelException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    CalulatorGUI frame = new CalulatorGUI();
                    frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the …