How to read a String from a simple text file.

I have a set up popup reminders, the content of which I have entered into a text file. I read the text and display it in a specially formatted JFrame/JPanel.
My question is, since readLine() has been deprecated, how do you read a simple line of text data from a file created by, say, notepad? I guess I could just use readLine() anyway, but I want to learn the language, and "playing by the rules" seems to be the way I should go.

I''m guessing your referring to the readLine method of DataInputStream. Use another class, like BufferedReader, which also happens to have a method named readLine:
BufferedReader in = new BufferedReader(new FileReader(filename));
try {
    String line;
    while ((line = in.readLine()) != null) {
        //process line
} finally {
    in.close();
}

Similar Messages

  • How to read a string from file & assign the val to a variable in batch file

    Hi,
    How to read a string from a file and assign the value to a variable then return the value to the screen in windows batch file?
    Any suggestions?
    thanks.

    Unless this is a homework question then I don't see the purpose of doing this, but....
    You should be looking a the supplied package utl_file to get the string out of the file, dbms_output to display the string and then google windows batch/command files calling sqlplus to execute your program.
    Andre

  • Read and write from and to text file

     Hi All,
    I am trying to read some portion of a text file and make measurement and calculation with those numbers and write back to the same text file and also to a excel file. I need to create a 2 D  array of 20 by 20 from the text file values and write to front panel table and to text file. but I am having problem with it, obviously I am new to this. Please help me.  thanks much
    ~ Johnny

    Hi Lynn,
    the requirement is to move C1 and C2 to each position that is given in the text file in steps and percentage value.
    for example C1 has to go to first step (5%) and C2 has to go thru all steps, 5% to 95% , in 5 percent increment. 
    each 100 steps translates to 1 percent increment in the capacitor value.
    at the end, I need to enter the measured data (values of C1 for each step, vesus all values of C2 for all steps) and enter them at the bottom of the text file's table where it starts at : "IMPEDANCE_REAL in Ohmone line per C1 position, containing all values for the different C2 positions" and do the same for where it says "IMPEDANCE_IMAGINARY in Ohmone line per C1 position, containing all values for the different C2 positions"
    the reason I read the file twice, is that if it read it once, I couldn't connect it to spreadsheet string to array vi.
    as you can see, I also like to use the write to measurement file and build table express vi's to display the table on the front panel and save the data to ni data file format so later I convert it to excel  too.
    any thoughts?
    thanks for your help
    ~ Johnny
    Attachments:
    read from text2.vi ‏82 KB

  • How do I stop TB from including a text file inline, instead of making it only an attachment?

    When I send text files, TB inserts them into the body, as well as attaching the files separately. I don't want them in the body, and I can't find a way not to do that. I've looked all through the options, but the only thing that's close refers to forwarding messages, and changing that did no good. Thank you.

    OK, that explains a little. On my Web-based mail system, the files are attached, not embedded. When I sync that account (IMAP) with TB on my desktop, they're both embedded and attached. Time to look at the options on my desktop.
    On the sending PC, TB shows the sent message with the text as both embedded and attached.
    I've used TB for several years on my desktop, and have never noticed this behavior. I just had to replace the other PC, and changed from Eudora to TB. Maybe all of the options aren't set right, so I'll compare them to my desktop's settings.
    I'm open to more suggestions if you have them.

  • How to read the last line in a text file using text_io?? please help

    Dear all
    I made a procedure that append text into a text file on the operating system.
    the text file grows rapidly. It contains now about 200,000 line . I need to read the last line only . In other wprds i need to go direct to the last line to read some values. Is it possible??
    Please help

    Hello,
    If you know the number of the line you want to read, I can sugget you to use the MORE dos command or the TAIL unix command that redirect to a temporary text file
    Example to create a file that contains the 200010th last lines :
    (Client)Host( 'MORE the_file_name.txt +200010 > small_file.txt') ;So you have only to read the small file with the TEXT_IO functions.
    Francois

  • How to read the contents from the provisioning jar file in 11g

    Hi All,
    I am new to OIM 11g, can anyone please let me know the process of reading the existing jar.
    Actually What I am trying to do is:
    1. I created one process task and added one task 2. Created adapter variables 3. Create java task and select the method.
    Here I am seeing jar name as javatasks.jar:icf-oim-intg.jar.
    method name as public.java.lang.string oracle.iam.connectors.icfcommon.prov.ICProvisoningManager.createObject(java.lang.object).
    I would like to see internal code of that jar files(means need to know how they are handling proviosoing).
    but I searched in all folders I could't able to find that jar. can any one please let me know how to find the icf-oim-intg.jar in 11g.
    Thanks,
    Valli
    Edited by: 988908 on Feb 26, 2013 10:05 PM

    check inside
    <OIM_HOME>/server/icf/intg/

  • How to read screendump image from clipboard to a file

    I am trying to build a program that runs minimized while other programs are being used at the same moment. At certain moments I want to make a screenshot and save that information to a image file on the harddisk.
    I have now the "user32.dll" to work and generate a "printscreen" push button. Now I want to write the information on the clipboard to an image file.
    How can I read the information on the clipboard and use it in a VI?
    Thanks in advance.
    Ferry

    If the screen you want to capture is a VI, you should use Invoke Node -> Get Panel Image, and Write BMP File.vi.
    See attached VI.
    If the screen isn't made in LabVIEW, and it's minimized, printscreen can't catch it.
    To save the clipboard image to file, you can import the clipboard image into LabVIEW first
    (use Image Toolbox: http://www.geocities.com/gzou999/imgtool.htm), and then Write BMP File.vi
    George Zou
    http://gtoolbox.yeah.net
    George Zou
    http://webspace.webring.com/people/og/gtoolbox
    Attachments:
    Save Panel.vi ‏25 KB

  • How to design and implement an application that reads a string from the ...

    How to design and implement an application that reads a string from the user and prints it one character per line???

    This is so trivial that it barely deserves the words "design" or "application".
    You can use java.util.Scanner to get user input from the command line.
    You can use String.getChars to convert a String into an array of characters.
    You can use a loop to get all the characters individually.
    You can use System.out.println to print data on its own line.
    Good luck on your homework.

  • How to read appended objects from file with ObjectInputStream?

    Hi to everyone. I'm new to Java so my question may look really stupid to most of you but I couldn't fined a solution by myself... I wanted to make an application, something like address book that is storing information about different people. So I decided to make a class that will hold the information for each person (for example: nickname, name, e-mail, web address and so on), then using the ObjectOutputStream the information will be save to a file. If I want to add a new record for a new person I'll simply append it to the already existing file. So far so good but soon I discovered that I can not read the appended objects using ObjectInputStream.
    What I mean is that if I create new file and then in one session save several objects to it using ObjectOutputStream they all will be read with no problem by ObjectInputStream. But after that if in a new session I append new objects they won't be read. The ObjectInputStream will read the objects from the first session after that IOException will be generated and the reading will stop just before the appended objects from the second session.
    The following is just a simple test it's not actual code from the program I was talking about. Instead of objects containing different kind of information I'm using only strings here. To use the program use as arguments in the console "w" to create new file followed by the file name and the strings you want save to the file (as objects). Example: "+w TestFile.obj Thats Just A Test+". Then to read it use "r" (for reading), followed by the file name. Example "+r TestFile.obj+". As a result you'll see that all the strings that are saved in the file can be successfully read back. Then do the same: "+w TestFile.obj Thats Second Test+" and then read again "+r TestFile.obj+". What will happen is that the strings only from the first sessions will be read and the ones from the second session will not.
    I am sorry for making this that long but I couldn't explain it more simple. If someone can give me a solution I'll be happy to hear it! ^.^ I'll also be glad if someone propose different approach of the problem! Here is the code:
    import java.io.*;
    class Fio
         public static void main(String[] args)
              try
                   if (args[0].equals("w"))
                        FileOutputStream fos = new FileOutputStream(args[1], true);
                        ObjectOutputStream oos = new ObjectOutputStream(fos);
                        for (int i = 2; i < args.length ; i++)
                             oos.writeObject(args);
                        fos.close();
                   else if (args[0].equals("r"))
                        FileInputStream fis = new FileInputStream(args[1]);
                        ObjectInputStream ois = new ObjectInputStream(fis);
                        for (int i = 0; i < fis.available(); i++)
                             System.out.println((String)ois.readObject());
                        fis.close();
                   else
                        System.out.println("Wrong args!");
              catch (IndexOutOfBoundsException exc)
                   System.out.println("You must use \"w\" or \"r\" followed by the file name as args!");
              catch (IOException exc)
                   System.out.println("I/O exception appeard!");
              catch (ClassNotFoundException exc)
                   System.out.println("Can not find the needed class");

    How to read appended objects from file with ObjectInputStream? The short answer is you can't.
    The long answer is you can if you put some work into it. The general outline would be to create a file with a format that will allow the storage of multiple streams within it. If you use a RandomAccessFile, you can create a header containing the length. If you use streams, you'll have to use a block protocol. The reason for this is that I don't think ObjectInputStream is guaranteed to read the same number of bytes ObjectOutputStream writes to it (e.g., it could skip ending padding or such).
    Next, you'll need to create an object that can return more InputStream objects, one per stream written to the file.
    Not trivial, but that's how you'd do it.

  • Reading Each String From a text File

    Hello everyone...,
    I've a doubt in File...cos am not aware of File.....Could anyone
    plz tell me how do i read each String from a text file and store those Strings in each File...For example if a file contains "Java Tchnology forums, File handling in Java"...
    The output should be like this... Each file should contains each String....i.e..., Java-File1,Technology-File2...and so on....Plz anyone help me

    The Java� Tutorials > Essential Classes: Basic I/O

  • How to convert a string from upper case to lower case in FOX formula

    Hi Experts,
    How to convert a string from upper case to lower case in FOX formula?
    Thanks,
    Cheers!!!
    PANKAJ

    The last result.append( c ) should be:
    result.append( Character.toLowerCase(c) );

  • Read 2 Strings from EXCEL with GOOP or ActiveX?

    Hello,
    i use Labview 5.1 with WIN NT4.0 SP6a and i programm a fuzzy Logic tool for a exam in Computer Science.
    Now i have a problem, and i read something about the GOOP and the EXCEL Toolkit. I download it and try more times to install but i can't link the *.llb in the Function Palette. Is this GOOP and Excel Toolkit only for Labview 6.x ?
    I solve it with ActiveX and Excel, but my very big Problem is, i need to read2 string from the Excel table from the same time, and with ActiveX i don't find any method how can i do that.
    I don't know how can i read 2 Strings from a Excel table, Can i do it with the Excel Toolkit,if yes how, maybe anyone make it or any helpfiles?
    Thanks for your answer in advance ,
    Ender
    Ekinci

    "fuzzylogic" wrote in message
    news:[email protected]..
    > Hello,
    > i use Labview 5.1 with WIN NT4.0 SP6a and i programm a fuzzy Logic
    > tool for a exam in Computer Science.
    > Now i have a problem, and i read something about the GOOP and the
    > EXCEL Toolkit. I download it and try more times to install but i can't
    > link the *.llb in the Function Palette. Is this GOOP and Excel Toolkit
    > only for Labview 6.x ?
    >
    > I solve it with ActiveX and Excel, but my very big Problem is, i need
    > to read2 string from the Excel table from the same time, and with
    > ActiveX i don't find any method how can i do that.
    >
    > I don't know how can i read 2 Strings from a Excel table, Can i do it
    > with the Excel Toolkit,if yes how, m
    aybe anyone make it or any
    > helpfiles?
    I'm pretty sure the excel toolkit is written for 5.1, and don't know why it
    would give you problems. Do you have excel installed? I'm not sure what
    you mean that you cant link the *.llb in function pallette. Have you tried
    opening the llb using '\functions\select a vi' ? As to how to read two
    cells at once, you could read a block of cells including both cells (ie:
    A5..D10) and then pull the data out of the array.

  • How to read a data from USB port using JAVA

    hi all,
    i need to know how to read a data from USB port using java. any API are available for java ?.........please give your valuable ideas !!!!!!!!!
    Advance Thanks!!

    You can do this. Please use this link
    [http://www.google.co.in/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=uHu&q=java+read+data+from+usb+port&btnG=Search&meta=&aq=f&oq=]
    What research did you do of your own? Have you done some testing application and tried yourself??

  • 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 to read Group ID from Value Mapping Context in Cache Monitoring ?

    Hi friends,
        In RWB --> Cache Monitoring --> Integration Server (Java) -> (Search for Value Mapping Groups) in this each item is identified by Value Mapping Group (GroupID, Context, Identifier/Agency, Identifier/Scheme). Either we create Value Mapping Table in ID or replicate value mapping data directly from text file/SAP table etc., in run time cache, data will be identified in this manner.
        Now, our requirement is to delete a record the Cache for a particular context. Two operations provided by XI one is 'Delete' and another one is 'DeleteGroup'. When we use either of this, we should know GroupID. Suppose, I replicated some large amount of data from my text file in Runtime Cache. Value Mapping Table is like that IN --> India, US --> USA, AU --> Australia, EG --> Egypt. Now, I am required to write a program to get the input country code from user which is going to delete in the value mapping table like IN/AU....  For this, what logic we should follow in the program is, First we scan the value mapping table and find the record (country code)  which is match with the input. Then find the GUID value for this record. Now we use the DeleteGroup Operation and pass this GUID and then delete the record.
        So, in essence, how to read the GUID from value mapping context.
        Friends, Kindly help me to do this.
    Thanks in advance.
    Jegatheeswaran P.

    Did you get the way to read group id?

Maybe you are looking for

  • Adding JAR file to project

    Hi All How can i add jar to my project environment. Actually what i did was. Created one folder called "JavaWork" like d:\JavaWork and put the jar file into this folder and wrote a test class which is importing some classes from the jar file. how to

  • My windows 8.1 desktop won't recognize my ipod nano 5th or 6th gen. Help please!!

    My windows 8.1 computer doesn't recognize my Ipod Nano 5th or 6th gen when plugged into USB while ITunes is on. Please help

  • Basic Feature missing in Acrobat Reader 7

    I am totally disappointed, that comments can't be printed by Acrobat Reader 7. I have just upgraded to Acrobat Prof 7 and Reader 7, expecting to enable projects partners printing comments. Tests have shown, editing comments works absolutely fine in b

  • Save as PDF and Save PDF as PostScript options in the Printer dialog are not supported.

    I downloaded Indesign CS3 trial and liked everything about it until I attempted to print to postscript and got that message. Nothing I have tried has helped. I have seen in various forums that others are having the same problem, but haven't found any

  • Threaded Blocking FTP Call

    Hello all I've recently implemented a program that will FTP some files across a network using the com.enterprisedt.net.ftp.FTPClient class and package from www.enterprisedt.com. Thus I know this might be a question for them but I was wondering why my