How to store the data?

Hi,
I'm new here, new to java
I have a java polymorphism question here, I have three classes,
Bicycle.java
public class Bicycle {
public void printClassName() {
System.out.println("Bicycle");
MountainBike.java
public class MountainBike{
public void printClassName() {
System.out.println("MountainBike");
TestBike.java
public class TestBike {
public ststic void main(String[] args) {
String type = "MountainBike";
Bicycle bike = new "type()";
bike.printClassName();
definitely, the type() is not correct here, is there any way to init the bike with a dynamic class without using switch/case?
Thanks.
peter

thanks, everyone, I got it finally.
actually, MountainBike is a subclass of Bicycle, I had a typo here,
my code something like that using java reflection,
TestBike.java
public class TestBike {
public ststic void main(String[] args) {
String type = "MountainBike";
CLass c = Class.forName(type);
Method m = c.getDeclareMethod("printClassName", null);
Object i = c.getnewInstance();
Object r = m.invoke(i, null);
I never used newInstance before, don't know the performance, because I may have lots of newInstance called.
sorry for the misleading of subject, actually, I want to ask another question to store data,
I had more than 40 files, I'd like to create a big xml to store the info of these files, like
<A>
<column>
<name>AC1</name>
<size>4</size>
<name>AC2</name>
<size>3</size>
</column>
</A>
<A2>
<column>
<name>A2C1</name>
<size>4</size>
<name>A2C2</name>
<size>3</size>
</column>
</A2>
because A, A2 is not a constant, I don't know how to parse the xml file with java, or I create seperate xml file like
A.xml
<column>
<name>AC1</name>
<size>4</size>
<name>AC2</name>
<size>3</size>
</column>
any idea?
Thanks.
peter

Similar Messages

  • How to store the datas in a .txt file in to a JTable in Java Swing

    Hi sir,
    Here i want to know how to store the data's of a .txt file
    in to a JTable in java swing.
    Where here the .txt file like for eg,spooler.txt is in the server and from there it will come to my client machine what i have to do is to take that .txt file and store the datas of the .txt file
    in a JTable.This is what i want.So pls. do help and provide the code as well.I will be thankful.Since i am involved in a project which involves this it is Urgent.
    Thanx,
    m.ananthu

    You can't just display data from a text file in a JTable. You have you understand the structure of the data so that you can parse the data and create a table model that can access the data in a row/column format. Here is an example of a simple program that does this:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=315172

  • How to store the data coming from network analyser into a text or excel file

    Hii everyone
    I'm using Agilent 8719ET network analyser and wish to store the data coming from netowrk analyser into a text file/ excel file.
    Presently I'm able to get the data on Labview graph using GPIB . Can anyone suggest how to go ahead after collect data sub vi. How can the data be stored into a file apart from showing on the graph?
    Attached is the vi for kind consideration...
    Looking for help
    Regards
    Rohit
    Attachments:
    Agilent 87XX Series Exceed Max Meas.vi ‏43 KB

    First let me say that your code really looks pretty good. The data handling could be made more efficient by calculating the number of datapoints that are going to be in the completed dataset and preallocating the entire array -- but depending upon your answer to my questions, the logic in the lower shift register may be going away - so we won't worry about that right now.
    The thing I need to know before addressing the data storage question is: Each time you call "Collect and Display Data.vi", how many element are in the array? Are you reading single data points, or a group of data? (BTW: if the answer to that question is obvious based on the way the other VIs are setup, I don't have the drivers so I can't tell what the setup values are.) Second, how fast does the loop iterate? Are we talking msec per loop?, seconds? fortnights?
    The issues here are two-fold: how much data? and how fast is it coming? The answer to these will tell you how to save the data.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • How to store the data of a file into an ArrayList?

    Hi! everyone.
    I want to know
    if I have a File, and the data in the file are type int, type String...
    And I have a ArrayList which is of type Question
    How do I store the data of that file into the ArrayList
    I tried to use the while loop(use the hasNextLine() to read the data line by line)
    But I cannot add data which are not of type Question to the ArrayList.
    Can you tell me what I should do, please?
    I also wonder that
    The data of the file are of many types, but when I try to read it with the nextLine(), the data all turn out to be of type String. Why?
    Thank you.
    Edited by: Terry001 on Apr 30, 2008 1:13 PM

    No, a line in the file is just part of a question
    The format of the file is like this:
    *<question type code>                    :     String*
    *<question point value>                    :     int*
    *<question category>                         :     String*
    *<question difficulty level>               :     int*
    *<question text>                              :     String*
    *<question correct answer>               :     String*
    *<optional question-specific data>     :     String*
    *<question terminator>                    :     String*
    And here is an example
    TF //TrueFalseQuestion
    5 //points value
    None //category
    3 //difficulty level
    The capital of the United States is Washington, D.C. //question text
    True // answer
    *** //quetion terminator
    I created an ArrayList in the Test class:
    private ArrayList<Question> questions; // Create inside constructor
        public Test (String name, String instr)
            testName = name;
            scoreEarned = 0;
            scorePossible = 0;
            instructions = instr;
            questions = new ArrayList<Question>(); //[MAX_NUMBER_OF_QUESTIONS];
        }And I tried to use the following method to store the data of the file to the ArrayList
    // This method loads a set of questions from a plain text file
        public void loadQuestionsFromFile(String fileName) throws FileNotFoundException
            try
                File fileReader = new File("input.txt");
                Scanner sc = new Scanner(fileReader);
                while (sc.hasNextLine())
                    // I don't know how to pass the data I got from the nextLine() method to the ArrayList because they are of different type
            catch (FileNotFoundException a)
                System.out.println(a);
        }    As all you said, I should create an Question object in the while loop
    Question temp = new Question ();But I have no idea how to pass the int and String to the Question object.
    Thank you

  • How to store the data instead of memoryengine to database when use XML file

    Hi Experts,
    I have doubt which is into XML to database data transfer.
    While transferring the data from XML to database the tables will be store in memory for the xml files, my aim is instead of storing this in memory engine
    is there any way to store the data in to the data base itself..
    I am assuming when the data size increases say for example huge amount data, storing this much of data is big issue here right, so to avoid this is there any way to store
    this data directly in the database level.
    Please understand my requirement or else I have the good explanation about my requirement and please assist me how do this job....
    Thx,
    Sahadeva.

    Hi Experts,
    For this job I have applied the
    jdbc:snps:xmll?f=/mydata/xml/file.xml&s=wrk_admin&dp_driver=oracle.jdbc.driver.OracleDriver&dp_url=jdbc:oracle:thin:@localhost:1521:xel&dp_user=wrk_admin&dp_password=bPyXS2eRXw8fWnKEmTYSEf&dp_schema=wrk_admin&dp_doc=Y
    my schema name is wrk_admin
    xml file name is mydata
    jdbc driver: localhost:1521:xe
    Encoded password: I have encoded the pwd from cmd:c:oracle\oracle_odi1\oracledi\agent\bin\encode wrk_admin
    The above are the details I have applied to my ODI studio for creating the dataserver.
    After applying this I got the following error.
    Could you please correct me here if I am wrong...
    jdbc:snps:xml?param1=value1&param2=value2&...
         at oracle.odi.jdbc.datasource.LoginTimeoutDatasourceAdapter.doGetConnection(LoginTimeoutDatasourceAdapter.java:133)
         at oracle.odi.jdbc.datasource.LoginTimeoutDatasourceAdapter.getConnection(LoginTimeoutDatasourceAdapter.java:62)
         at com.sunopsis.sql.SnpsConnection.testConnection(SnpsConnection.java:1118)
         at com.sunopsis.graphical.dialog.SnpsDialogTestConnet.getLocalConnect(SnpsDialogTestConnet.java:420)
         at com.sunopsis.graphical.dialog.SnpsDialogTestConnet.localConnect(SnpsDialogTestConnet.java:860)
         at com.sunopsis.graphical.dialog.SnpsDialogTestConnet.jButtonTest_ActionPerformed(SnpsDialogTestConnet.java:806)
         at com.sunopsis.graphical.dialog.SnpsDialogTestConnet.connEtoC1(SnpsDialogTestConnet.java:165)
         at com.sunopsis.graphical.dialog.SnpsDialogTestConnet.access$1(SnpsDialogTestConnet.java:161)
    Thx,
    Sahadeva.

  • How to store the data coming from visa into file

    Hi ,
    I want to store the data into text file,which is coming from visa-read.
    I tried visa read to file ,but it's not working.
     Am new to labview plz help me out.
    Thanks in advance. 

    CSFGF wrote:
    Hi ,
    I want to store the data into text file,which is coming from visa-read.
    I tried visa read to file ,but it's not working.
     Am new to labview plz help me out.
    Thanks in advance. 
     Share the code you have so far with us so that we can check what's going wrong.

  • How to store the data captured from oscillosco​pe into the MS Access database table

    Hi All,
    In my application, I tried to save the data captured from SCOPE, but could store only 200 bytes. I've taken the Memo data type for the field in database. I want to store all data ( 4 channels) in one field & retrieve back and display on the XY Graph.
    Thanks in advance.
    Regards,
    Shrini

    kramish wrote:
    Im pretty sure that Access does support JDBCNo it does not. It supports ODBC.
    just doing a quick Google came up with some pages:
    http://blog.taragana.com/index.php/archive/access-microsoft-access-database-from-java-using-jdbc-odbc-bridge-sample-code/
    http://www.javaworld.com/javaworld/javaqa/2000-09/03-qa-0922-access.html
    Both articles explains how to use the jdbc-odbc bridge. I think I've seen a pure jdbc driver for access but it wasn't from Microsoft and it wasn't free.
    Kaj

  • How to store the data read from excel using java code in Ms access database

    Hi. I wrote a code to read the data from excel. May i know how can i save it to Ms access database using java. Also i have many excels. So i should not connect the database using DSN. So is there any other way to achieve this?

    kramish wrote:
    Im pretty sure that Access does support JDBCNo it does not. It supports ODBC.
    just doing a quick Google came up with some pages:
    http://blog.taragana.com/index.php/archive/access-microsoft-access-database-from-java-using-jdbc-odbc-bridge-sample-code/
    http://www.javaworld.com/javaworld/javaqa/2000-09/03-qa-0922-access.html
    Both articles explains how to use the jdbc-odbc bridge. I think I've seen a pure jdbc driver for access but it wasn't from Microsoft and it wasn't free.
    Kaj

  • How to store the data, which should accessed by all the users

    I want to store some data into some variables, which has to be accessed by all the users on the webserver. i think it has to be stored in the application memory but if any body gives the code it will be clear to me .
    Thank Q
    K.Srinivas

    if it is for the same webapplication you can keep it in static attributes in a class which can be loaded at the time of server startup

  • How to store the data typed in flash to .txt file?

    Hi all,
    I have a query to all, I have created a notepad in flash, if I typed something in that and save that file as .txt format in my local drive. So, any help on the same....
    Thanks in advance
    Santhosh Kumar M

    i don't think this is complicated enough for anyone to write a tutorial.  but i could be wrong about that.
    you have 2 steps:
    1.  use the urlloader class to send data to a server-side php script that saves your data to a .txt file
    2.  use the filereference class to download that file.
    they're both pretty easy if you use the flash help files to start you off.

  • Re: how to store the data from the Buffer as a Jpeg files?

    FrameGrabbingControl fgc = (FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");
    Buffer buf = fgc.grabFrame();
    BufferToImage bti=new BufferToImage(new VideoFormat(VideFormat.JPEG););
    Image img = bti.createImage( buf );

    Is there a simple way to set up a frame callback that presents each frame of the callback in the standard java image class, such that it can be used directly with the Java 2D API, and also the Java Advanced Imaging API?

  • How to record the data against time?

    Hi there,
    I am doing a real-time measurement, and i get a 1-D dataflow  from the loading cell without time stamp.  I know how to record it and save it to a file. However, how to store the data against time? I know I can use "get date time in seconds.vi" to obtain the system time, but how to integrate it with the dataflow from the loading cell? it would be best if I can view the dataflow changing with respect to the system time in a waveform chat.
    Thanks.
    Mike

    You are doing a measurement with what? NI DAQ card or something else? The chart and saving to file are two different things. For an example of displaying time in a chart, look at the example called Real-Time Chart. How exactly do you want the time/measurement data written to file?

  • I am receiving the data through the rs232 in labview and i have to store the data in to the word file only if there is a change in the data and we have to scan the data continuasly how can i do that.

    i am receiving the data through the rs232 in labview and i have to store the data in to the word or text file only if there is a change in the data. I have to scan the data continuasly. how can i do that. I was able to store the data into the text or word file but could not be able to do it.  I am gettting the data from rs232 interms of 0 or 1.  and i have to print it only if thereis a change in data from 0 to 1. if i use if-loop , each as much time there is 0 or 1 is there that much time the data gets printed. i dont know how to do this program please help me if anybody knows the answer

    I have attatched the vi.  Here in this it receives the data from rs232 as string and converted into binery. and indicated in led also normally if the data 1 comes then the led's will be off.  suppose if 0 comes the corresponding data status is wrtten into the text file.  But here the problem is the same data will be printed many number of times.  so i have to make it like if there is a transition from 1 to o then only print it once.  how to do it.  I am doing this from few weeks please reply if you know the answer immediatly
    thanking you 
    Attachments:
    MOTORTESTJIG.vi ‏729 KB

  • How to read the data from Excel file and Store in XML file using java

    Hi All,
    I got a problem with Excel file.
    My problem is how to read the data from Excel file and Store in XML file using java excel api.
    For getting the data from Excel file what are all the steps i need to follow to get the correct result.
    Any body can send me the code (with java code ,Excel sheet) to this mail id : [email protected]
    Thanks & Regards,
    Sreenu,
    [email protected],
    india,

    If you want someone to do your work, please have the courtesy to provide payment.
    http://www.rentacoder.com

  • How can i store the data from the list to MS-Access?

    Hi all,
    We all know that from alv it is possible to export data to Ms-excel or word or text file. Can anyone tell me how can i store the data from alv or reports to Ms-Access?
    Thanks in Advance,
    Abhijit

    Hi,
    If you want that without code, i suppose there is a option in MS-Access to import data from Excel, so you have to first export to excel and then import to Access.
    If you want to code it yourself then have a look at FM TABLE_EXPORT_TO_MSACCESS, as said in Exporting Data from R/3 to MS ACCESS
    You can also see the search results in SCN for [export data to MS-Access (45 Results)|https://www.sdn.sap.com/irj/sdn/advancedsearch?query=exportdatato+MS-Access&cat=sdn_all].
    Regards
    Karthik D

Maybe you are looking for

  • How can I remove the junk mail folder from appearing in my macbook mail program?

    Hi all Can someone please tell me how I can remove the "junk" mailbox from showing in my mail program on my macbook? It wasn't there before and I would like it removed. I've attached a screen shot to be clearer in my request. Thank you!

  • Qosmio G30: Cannot install Windows 7 due to missing RAID driver

    Hi, I have been trying to instal Win 7 Home Premium in G30 running Win XP (Media Edition) without success. The issue is Toshiba Raid driver is missing. I have since download and install new driver (V1.10.0016). Still Win 7 upgrade s/w didn't recongis

  • Groovy expression evaluation

    Hi, The following groovy expression is returning null when validating attribute. If I use (PolicyNum > 2000000) in the if condition it is working fine. If use (newValue < MaxManualClassEndDate) in the if condition that is also working as expected. if

  • Authentication failure

    I erased my system folder then reinstalled Lion 10.7.3.  My login in formation (both administrative and password) no longer work. I have the correct login information.  I tired to change it via Terminal but it won't let me change the password. Is the

  • Version/Build number hasn't incremented after updates

    Hi, I've deployed another ColdFusion 10 RHEL6 server and due to some firewall issues it isn't able to connect to the update center to grab the hotfixes. So I copied the jar files from another server that I was able to update successfully and ran all