How to get data from a file?

Hello everyone, i'm new to this forum and to java too. Ok, so here is what i want to do:
I want to get data from a file containing words and numbers and store them into variables that i will use them after to insert into a database table. For example i have a file called employees.txt in this form:
eid ename zipcode Hire_date
1000 "Jones" 67226 "12-DEC-95"
In C++ i declare variables for each data and store them, for example in this case:
ifstream in("somefile");
string name, hdate;
int eid, zip;
in >> eid >> ename >> zip >> hdate;
So i want to do the same thing in JAVA but i can't make it work. So, i would appreciate if someone could give me a simple example how to do it. Thank you.

[http://java.sun.com/docs/books/tutorial/essential/io/index.html]

Similar Messages

  • Help Me... How to get Data from CSV File...?

    Hi Everyone..!
    This is yajiv and am working in CS3 Photoshop platform. I know about Java Script. Is it possible to get the data from CSV files. Actually our client use to send us the CSV files which contains a lot of swatch name and reference files in one particular image name.
    Actually how we work on that CSV file is, first we copy file name to search that CSV file. then get the result to paste into layer name. This process continue till the end of swatch.
    Thank in Advance
    -yajiv

    > Is it possible to get the data from CSV files.
    Have you tried searching this forum?

  • How to get data from media files such author, title and so on

    Hi you all!

    You'd have to parse the binary file header yourself. JMF doesn't have any built-in ways to extract META data from media files.
    Also, don't post your question in the title and not in the body of the message. It's annoying and stupid...

  • How to get data from XML file having korea Text

    I have a one XML File with Korean Text, How to read this File.
    i tried with this code
    BufferedReader in = new BufferedReader(
    new InputStreamReader(new FileInputStream("C:/test1.xml"), "EUC-KR"));
    String str = in.readLine();
    but it is giving exceptions.
    please suggest me, how to retrive EUC-KR text from the XML file

    Standard Java does not support this Charset. You have to find a charset provider that implements "EUC-KR". But you should also consider using Unicode, which is implemented in standard Java.
    http://www.unicode.org/charts/

  • How to get data from pdf file and send contents  of the pdf file to R/3

    Hi, experts,
    Action:
    1. Make a pdf forms (interactive form) with inputfield named “A_inputfield” in the webdynpro application and run the webdynpro application.
    2. In the IE, click the save button in the pdf interactive form and save the pdf to local disk,ex: C disk. Close the IE browser.
    3. Open the pdf interactive form from the local C disk and type "aaa" to the “A_inputfield”.
    4. I want to save the "aaa" to the R/3 system using webdynpro or using other tools . How can I do it?
    First way:
    If I use webdynpro application to save the content of the pdf, I don't find a way mapping or binding the content to a context of a view. So I don't think this way is unadvisable.
    Second way:
    Adding a button "submit" in the pdf forms when create the pdf form. Runing the webdynpro application, save the pdf to local disk,ex: C disk.  Opening the pdf interactive form from the local c disk and typing "aaa" to the “A_inputfield”, click the  "submit" button to save the content. Of course, I need to finish the code for clicking "submit" button. But I don't know how  to write these codes and where to write these codes. Do you give me some advise ?
    Best regards,
    tao

    Hi, Abhimanyu L,
    Thanks a lot for your help. Your answer can give me large developmental.:)
    I find http://help.sap.com/saphelp_erp2005/helpdata/en/67/fae9421dd80121e10000000a155106/content through searching google for CL_WD_ADOBE_SERVICES class. But I don't find any exmples for the class. Do you give me some hint for some exmples for the class?
    Best regards,
    tao
    (You can reply back to me via e-mail if you think we should discuss this internally at [email protected] or [email protected])

  • Cant get data from text file to print into Jtable

    Instead of doing JDBC i am using text file as database. I cant get data from text file to print into JTable when i click find button. Goal is to find a record and print that record only, but for now i am trying to print all the records. Once i get that i will change my code to search desired record and print it. when i click the find button nothing happens. Can you please take a look at my code, dbTest() method. thanks.
    void dbTest() {
    DataInputStream dis = null;
    String dbRecord = null;
    String hold;
    try {
    File f = new File("customer.txt");
    FileInputStream fis = new FileInputStream(f);
    BufferedInputStream bis = new BufferedInputStream(fis);
    dis = new DataInputStream(bis);
    Vector dataVector = new Vector();
    Vector headVector = new Vector(2);
    Vector row = new Vector();
    // read the record of the text database
    while ( (dbRecord = dis.readLine()) != null) {
    StringTokenizer st = new StringTokenizer(dbRecord, ",");
    while (st.hasMoreTokens()) {
    row.addElement(st.nextToken());
    System.out.println("Inside nested loop: " + row);
    System.out.println("inside loop: " + row);
    dataVector.addElement(row);
    System.out.println("outside loop: " + row);
    headVector.addElement("Title");
    headVector.addElement("Type");
    dataTable = new JTable(dataVector, headVector);
    dataTableScrollPane.setViewportView(dataTable);
    } catch (IOException e) {
    // catch io errors from FileInputStream or readLine()
    System.out.println("Uh oh, got an IOException error!" + e.getMessage());
    } finally {
    // if the file opened okay, make sure we close it
    if (dis != null) {
    try {
    dis.close();
    } catch (IOException ioe) {
    } // end if
    } // end finally
    } // end dbTest

    Here's a thread that loads a text file into a JTable:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=315172
    And my reply in this thread shows how you can use a text file as a simple database:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=342380

  • How to get Text from (.txt) file to display in the JTextArea ?

    How to get Text from (.txt) file to display in the JTextArea ?
    is there any code please tell me i am begginer and trying to get data from a text file to display in the JTextArea /... please help...

    public static void readText() {
      try {
        File testFile = new File(WorkingDirectory + "ctrlFile.txt");
        if (testFile.exists()){
          BufferedReader br = new BufferedReader(new FileReader("ctrlFile.txt"));
          String s = br.readLine();
          while (s != null)  {
            System.out.println(s);
            s = br.readLine();
          br.close();
      catch (IOException ex){ex.printStackTrace();}
    }rykk

  • How to read data from a file that was formatted by excel?

    Hi everyone, I'm familiar with java.io and the ability to read from files, can anyone tell me how to read data from a file that was formatted by excel? Or at least give me some web references so that I can learn about it?

    http://jakarta.apache.org/poi/hssf/index.html
    HSSF stands for Horrible Spreadsheet Format, but it still works!

  • How to get data from a USB-UIRT device using Labview?

    How to get data from a USB-UIRT device using Labview?
    I'm trying to get data from a USB-UIRT device, is it posible with Labview?
    I really appreciate your help, 
    thanks

    You may want to contact the developer of the device for the API and DLL.
    http://65.36.202.170/phpBB2/viewforum.php?f=3

  • How to extract data from XML file with JavaScript

    HI All
    I am new to this group.
    Can anybody help me regarding XML.
    I want to know How to extract data from XML file with JavaScript.
    And also how to use API for XML
    regards
    Nagaraju

    This is a Java forum.
    JavaScript is something entirely different than Java, even though the names are similar.
    Try another website with forums about JavaScript.
    For example here: http://www.webdeveloper.com/forum/forumdisplay.php?s=&forumid=3

  • How to get data from three tables (A,B,C) having one to many relation between A and B .and having one to many reation between b and c

    i have  three tables A,B,C.  there is one to many relation between A and B. and one to many relation existed between table b and c . how will get data from these three tables

    check if this helps:
    select * --you can always frame your column set
    from tableA a
    left join tableB b on a.aid=b.aid
    left join tableC c on c.bid=b.bid
    This is just a general query. However, we can help you a lot more, if you can post the DDL + sample data and required output.
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • How to insert data from *.dmp file to  oracle 11g using Oracle SQL Develope

    hi
    i backup my database using PL/SQL developer and made *.dmp file
    how to insert data from *.dmp file to oracle 11g using Oracle SQL Developer 2.1.1.64
    and how to make *.dmp file from sql*plus ?
    thanks in advance

    Pl/Sql developer has a config window, there you choose the exec to do the import/export.
    Find it and his home version, it may be exp or expdp, the home version is the version of the client where the exp executable is.
    Then use the same version of imp or impdp to execute the import, you do not need to use Oracle SQL Developer 2.1.1.64. If you want to use it, you must have the same version in the oracle home that exp/imp of sql developer use.

  • How to read data from multiple files and append in columns in one file

    Hi Guys,
    I have a problem in appending data from files in different columns. I have attachement has file A and B which I am reading and not able to get data as in file Result.txt. Please comment on how can I do this
    Solved!
    Go to Solution.
    Attachments:
    Write to file.vi ‏13 KB
    A.txt.txt ‏1 KB
    B.txt.txt ‏1 KB

    You cannot append columns to an existing file. Since the data is arrange line-by-line as one long linear string in the file, you can only append rows. A new row needs to be interlaced into the original file, shifting everything else. If you want to append rows, you need to build the entire output structure in memory and then write all at once.
    (I also don't think you need to set the file positions, it will be remembered from the last write operation.)
    Unless the files are gigantic, here's what I would do:
    (Also note that some of your rows have an extra tab at the end. If this is normal, you need a little bit more code to strop out empty columns. I include cleaned up files in the attachment. I also would not call them A.txt.txt etc. A plain A.txt is probably sufficient.)
    EDIT: It seems Dennis's solution is similar )
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Write to fileMOD.zip ‏6 KB
    MergeColumns.png ‏6 KB

  • How to extract data from .xltm file in a (dataset, datatable or a list) using wpf c#

    Hi all,
    As we can get data from .xls, .xlsx file in a dataset. Now i want to read all the entire data from .xltm file.
    I also want to get all sheets name from .xltm file. I am using .Net framework 4.5, Visual studio 2012.
    Please help me. I am unable to extract it. It is urgent.

    Hello Kalpna Bindal,
    I just investigate this issue and use the following way but it does work:
    private void Button_Click(object sender, RoutedEventArgs e)
    // initialize connection
    OleDbConnection con = new OleDbConnection();
    con.ConnectionString =
    "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\Fruits1.xltm;Extended Properties=\"Excel 12.0 Xml;HDR=YES;\"";
    //pass query to Insert values into Excel
    OleDbCommand cmd = new OleDbCommand();
    cmd.CommandText = "insert into [Sheet1$] values('')";
    cmd.Connection = con;
    // EXECUTE QUERY
    con.Open();
    cmd.ExecuteNonQuery();
    con.Close();
    I then did a research about this issue and find the following case:
    http://stackoverflow.com/questions/22225017/reading-excel-xltm-files-programmatically
    To test whether it is possible I use the following code in WPF:
    Microsoft.Office.Interop.Excel.Application xltmApp = new Microsoft.Office.Interop.Excel.Application();
    xltmApp.Visible = false;
    xltmApp.ScreenUpdating = false;
    Workbook xltmBook = xltmApp.Workbooks.Open(@"D:\Fruits1.xltm");
    Worksheet xlworksheet = xltmBook.Worksheets.get_Item(1);
    for (int i = 1; i <= 1; i++)
    for(int j=1;j<=1;j++)
    string str = (string)(xlworksheet.UsedRange.Cells[i, j] as Microsoft.Office.Interop.Excel.Range).Value;
    MessageBox.Show(str);
    The result is that I can read this .xltm file and read the firstline without problem.
    I would think you can also use this way to work with your .xltm file and output it to your application.
    For more details about how to fill to your WPF, common wpf and excel thread will be helpful:
    http://www.codearsenal.net/2012/06/c-sharp-read-excel-and-show-in-wpf.html#.URPyfPJJocU
    http://www.dotnetcurry.com/showarticle.aspx?ID=988
    http://mozouna.com/Blog/2013/03/28/wpf-reading-and-writing-to-excel-file-with-c/
    By the way, for WPF case please post on WPF forum instead of C# forum.Best regards,
    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to get data from PDF form?

    PDF forms can send data in url like GET or POST method. Is it possible to get data from url, like in PHP http://sever/file.php?item1=value1&item2=value2&item3=value3
    In APEX url have specific construction and I don't know how to get value of items (1...3)
    Please let me help to find simple method of geting data from URL.
    Best Regards,
    Mark

    The APEX URL syntax is detailed here
    http://download.oracle.com/docs/cd/E14373_01/appdev.32/e11838/concept.htm#BCEDJBEH
    How to get it from PDF is another matter...
    I'm working on an app that downloads PDFs with a Large amount of data as a blob, takes that blob and changes it to XML, then goes through the xml to validate each section of data and then add it into the schema that my apex app is referencing....
    I didn't write the original code but I do know that it isn't a quick thing to implement and includes using some uploading some java jar files to your schema and writing some custom java code.
    Someone else may be able to help with grabbing PDF data into the URL for the amounts of data you want to pass to apex.
    Gus..
    REWARDS: Please remember to mark helpful or correct posts on the forum, not just for my answers but for everyone!
    Edited by: Gussay on Sep 21, 2009 5:52 PM

Maybe you are looking for

  • LOVS in JSP - No Combo

    Is it possible to create a LOV opening a "search window" in wich the user can search and select the value he wants and have back the value in the main form ? Any suggestion will be appreciated. TIA Tullio

  • VBOX Layout issue with offset of a few pixels for the 2nd and 3rd components.

    The VBox has 2 components, on clicking the toggle label on the left, one component is hidden and the other is made visible. How does one get rid of the padding at the top when the 2nd component is displayed. At the end of the script are two images wi

  • Using osx snow leopard with boot camp, optical drive keeps ejecting windows 7 disc

    Upgraded my late 2008 macbook pro from leopard to snow leopard.  Added the max 4GB of RAM and replaced the working 250GB hard drive with a new 1TB hard drive.  Rebooted with time machine from external hard drive.  Now tried setting up Bootcamp to add

  • I pod video/firewire

    I mistakenly bought the i-pod adaptor (allowing the i-pod to plug into the wall to be charged) but my adaptor has the firewire connection as opposed to usb...(and I can't return it); could you tell me if I can buy firewire that will fit the adaptor a

  • Re:Payment terms need to be delete

    Dear Al, My client wants to delete some payment terms which is already exist in the system and they are already in the PO,SO and some Invoices. My doubt is if we delete the Payment terms is there any impact on open PO,SO and invoice ? Anyone have ide