Best way to read chars from InputStream

Hope this is not a too newbie question.
Suppose I have an unbuffered InputStream inputStream, what is the best way to read chars from it (in terms of performance)?
Reader reader = new BufferedReader(new InputStreamReader(inputStream));
reader.read()
or
Read reader = new InputStreamReader(new BufferedInputStream(inputStream))
reader.read()
Is there a difference between the two and if so, which one is better?
thanks.

If you are reading using a buffer of your own, then adding a buffer for binary data is a bad idea.
However for text, using a BufferedInputStream could be better as it reduces calls to the OS.
If it really matters, I suggest you do a simple performance test which runs for at least a few seconds to see what the difference is. (You should runt he test mroe than once)
Edited by: Peter__Lawrey on 20-Feb-2009 21:37

Similar Messages

  • How is the best way to read data from an iphone if you lost your itunes data after a crash?

    How is the best way to read data from an iphone if you lost your itunes data after a crash?

    How is the best way to read data from an iphone if you lost your itunes data after a crash?

  • The best way to read characters from a single line?

    my problem is i have is that 0-5 characters are on one line i need to split this up as each single letter stands for a word i.e - f = football. i need to separate each one. also a person can have up to five hobbies (the letters stand for likes or dislikes) so i also need to think about making sure a reader? stops after the line ends.
    any ideas on the best, most efficient method i could use to overcome this problem?
    thank you Aaron.

    String letters = "fgdat";
    char[] characters = letters.toCharArray();Try that out.

  • Best way to read from a file

    What would be the best way to read from a file. Which classes do I need to use?
    I have to write a program, which reads data from a comma separated flat file, parse it and after inserting some busineess logic insert into a databse .
    I will have to read the data line by line.
    Any help????

    I would use:
         public void readData()
              try
                   data = new String[this.countRows("comp.txt")][];
                   BufferedReader br = new BufferedReader(new FileReader("comp.txt"));
                   for(int x = 0; x < data.length; x++)
                        StringTokenizer temp = new StringTokenizer(br.readLine(), "?");
                        data[x] = new String[temp.countTokens()];
                        for(int y = 0; y < data[x].length; y++)
                             data[x][y] = temp.nextToken();
              catch(Exception e)
                   System.out.println(e.toString());
         private int countRows(String f)
              int t = 0;
              try
                   BufferedReader brCountRows = new BufferedReader(new FileReader(f));
                   while(brCountRows.readLine() != null)
                        t++;
              catch(Exception e)
                   System.out.println(e.toString());
                   return t;
              return t;
         }It works deliciously!

  • Best way to move photos from iPad to Mac?  I have a card reader foriPad and used it on a recent vacation to put pics on iPad.  How can I now move them to Mac?  Preferably without using iPhoto.

    Best way to move photos from iPad to Mac?  I have a card reader for iPad and used it on a recent vacation to put pics on iPad.  How can I now move them to Mac?  Preferably without using iPhoto.

    With iPhoto or with the Image Capture application.

  • What is the best way to read and manipulate large data in excel files and show them in Sharepoint

    Hi ,
    I have a large excel file that has 700,000 records in it. The excel file has a few columns that change every day.
    What is the best way to read the data form the excel file in fastest and most efficient way.
    2 nd Problem,
    I have one excel file that has many rows each row contain some data that has certain keywords.
    What I want is  to segregate the data of rows into respective sheets(tabs ) in the workbook.
    for example in rows have following data 
    1. Alfa
    2beta
    3 gama
    4beta
    5gama
    6gama
    7alfa
    in excel
    I want there to be 3 tabs now with each of the key words alfa beta and gamma.

    Hi,
    I don't really see any better options for SharePoint. SharePoint use other production called 'Office Web App' to allow users to view/edit Microsoft Office documents (word, excel etc.). But the web version of excel doesn't support that much records as well
    as there's size limitations (probably the default max size is 10MB).
    Regarding second problem, I think you need some custom solutions (like a SharePoint timer job/webpart ) to read and present data.
    However, if you can reduce the excel file records to something near 16k (which is supported rows in web version of excel) then you can use SharePoint Excel service to refresh data automatically in the excel file in SharePoint from some external sources.
    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com

  • How is the best way to remove something from a photo?

    How is the best way to remove something from a photo?

    This is difficult to answer without fully knowing what you are trying to do.
    That said, a few excellent and user friendly retouching tools include:  The Spot Heealing Brush Tool, Healing Brush Tool, Patch Tool, and the Cloning Stamp Tool.

  • What is the best way to import pictures from Lightroom 5 into FCP X

    What is the  best way to transfer pictures from Lightroom 5 into Final Cut Pro X?

    There is no one best way.  If, for instance, you want to be able to zoom into the picture with a Ken Burns effect then you may want to save out a very high res version that will be larger than your video resolution. Just use Lightroom to export a jpg file wherever you want it. You could export it into the Events folder and then choose not to copy it when you import it within FCPx. You could import the picture into iPhoto and then access it directly from within FCPx. Those are two simple, "regular" ways to get it into FCPx but if you are not going to Ken Burns the image by zooming into it and such you will want to crop it in Lightroom to the same size you will be using ie if you are making 720HD video then crop the image to that size and proportion before you export it from Lightroom.

  • What is the best way to import photos from aperture to my new Lightroom

    What is the best way to import photos from aperture to my new Lightroom ?

    See if this helps
    http://lightroomsolutions.com/articles/migrating-from-aperture-to-lightroom-where-do-i-beg in/

  • Best way to transfer files from old Macbook Pro to new one?

    I just got a new Macbook Pro from Apple...YEEEEAAAHHHH! 
    So....
    What's the best way to transfer files from old Macbook Pro to new one?  I know Migration assistant, but is there a recommended way?  I don't want to put do a system restore or transfer everything from the old laptop, but I do want to move important things like photos, music, documents and such over.  Any suggestions on best way to do this?
    Another question, perhaps subquestion.  If I have, say, an older version of iPhoto but a newer version of one on my new Macbook Pro, will it still transfer photos no problem?
    Just looking for hints from the experts so this puppy is set up in the best way possible.

    Just one comment on this:
    ‘If I have, say, an older version of iPhoto but a newer version of one on my new Macbook Pro, will it still transfer photos no problem?’
    the problems are ALWAYS in the reverse way, when you have the newest (or a newer) version of a given app, and wish to transfer its library to an older version.
    Otherwise, see the link to Pondini.
    I have been using Martin Jahn’s iBackup, with which I have become accustomed and works fine. It also makes daily backups. Its advantage over other apps is that you may add whatever you wish to save, beside its default settings (which you may delete or cancel, of course, even if not recommended); it also has a friendly interface and easily customizable. Of course, this is a personal view, you may try other methods as well, or other backup apps. All are good if you are satisfied and correspond to your needs.

  • What's the best way to transfer everything from my 5-year-old iMac to my 1-year-old iMac?

    What's the best way to transfer everything from my 5-year-old iMac to my 1-year-old iMac?
    I'm doing role reversal with these two.  The newer imac is becoming our business computer, the older one will be our personal computer from now on until it gives out.  For the record, I have Carbonite on the business unit.  Should be a no-brainer, right?  (Which is precisely why I'm asking!)
    Thanks for whatever timely and accurate advise you may have.

    Thanks. I stumbled across migration assistant later that afternoon in a google search. Just finished using it today to do the deed. Appreciate your quick response!

  • What's the best way for reading this binary file?

    I've written a program that acquires data from a DAQmx card and writes it on a binary file (attached file and picture). The data that I'm acquiring comes from 8 channels, at 2.5MS/s for, at least, 5 seconds. What's the best way of reading this binary file, knowing that:
    -I'll need it also on graphics (only after acquiring)
    -I also need to see these values and use them later in Matlab.
    I've tried the "Array to Spreadsheet String", but LabView goes out of memory (even if I don't use all of the 8 channels, but only 1).
    LabView 8.6
    Solved!
    Go to Solution.
    Attachments:
    AcquireWrite02.vi ‏15 KB
    myvi.jpg ‏55 KB

    But my real problem, at least now, is how can I divide the information to get not only one graphic but eight?
    I can read the file, but I get this (with only two channels):
    So what I tried was, using a for loop, saving 250 elements in different arrays and then writing it to the .txt file. But it doesn't come right... I used 250 because that's what I got from the graphic: at each 250 points it plots the other channel.
    Am I missing something here? How should I treat the information coming from the binary file, if not the way I'm doing?
    (attached are the .vi files I'm using to save in the .txt format)
    (EDITED. I just saw that I was dividing my graph's data in 4 just before plotting it... so It isn't 250 but 1000 elements for each channel... Still, the problem has not been solved)
    Message Edited by Danigno on 11-17-2008 08:47 AM
    Attachments:
    mygraph.jpg ‏280 KB
    Read Binary File and Save as txt - 2 channels - with SetFilePosition.vi ‏14 KB
    Read Binary File and Save as txt - with SetFilePosition_b_save2files_with_array.vi ‏14 KB

  • What's the best way to transfer footage from a Sony miniDVD camcorder?

    What's the best way to transfer footage from a Sony miniDVD camcorder?

    Do not use "mini" DVD's in any slot loading DVD drive.
    Buy a cheap "tray loading" external DVD drive and attach it to your Mac.

  • What are the best ways to share photos from iPhoto?

    What are the best ways to share photos from iPhoto?

    If you use Adobe Photoshop, or even Adobe Photoshop Elements, stay as far away from iPhoto as possible.
    iPhoto does not play nice with Adobe software or with software from any other third party developer.
    iPhoto will hide your image files in a library paradigm where you have no access to them other than through iPhoto.

  • How to read char from console

    Hi can any body help me..
    I want to read char from keybord. withought pressing ENTER.
    I am not sure how i can do it. I can't use
    BufferedReader br = new  BufferedReader(new InputStreamReader ( System.in )) ;
    char key ;
    key = (char )br.read() ;
    cuz i have to press ENTER every time to read char.
    Thanks in advance.

    try this,I' have found a part on Internet
    package exercises;
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    * questa � la classe d' esempio per leggere l'input dalla console*/
    public class Echo {
    public static void main(String args[]) throws Exception{
    // This is where the magic happens. We have a plain old InputStream
    // and we want to read lines of text from the console.
    // To read lines of text we need a BufferedReader but the BufferedReader
    // only takes Readers as parameters.
    // InputStreamReader adapts the API of Streams to the API of Readers;
    // receives a Stream and creates a Reader, perfect for our purposes.
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String input = "";
    while(true){
    System.out.print("ECHO< ");
    //As easy as that. Just readline, and receive a string with
    //the LF/CR stripped away.
    input = in.readLine();
    //Is a faster alternative to: if (input == null || input.equals(""))
    //The implementation of equals method inside String checks for
    // nulls before making any reference to the object.
    // Also the operator instance of returns false if the left-hand operand is null
    if ("".equals(input)){
    break;
    }else
    // Here you place your command pattern code.
    if ("ok".equals(input)){
    System.out.println("OK command received: do something �");
    //Output in uppercase
    System.out.println("ECHO> " + input.toUpperCase());
    System.out.println("ECHO> bye bye");
    //We exit without closing the Reader, since is standard input,
    // you shouldn't try to do it.
    // For all other streams remember to close before exit.
    }

Maybe you are looking for

  • How to make a login and logout in jsf  2.0 ?

    Hello all, i am developing an web application have login and logout component. I want to check whenever end user try to open admin/index.xhtml, it will be redirected to login.xhtml. And when end user click on log out button, i will be destroy session

  • MAJOR Ipod Mini Issues!!! HELP PLEASE!

    Oh My~lanta! I am just about at my wit's end w/ this too!!! I'm experiencing the same problems although it seems like everyday I get a new error message!!!! My computer crashed back in December and ever since, my IPOD has not been the same. I thought

  • Re: Using the real thing in blockquotes

    Thierry | www.TJKDesign.com wrote: > darrel wrote: >> The article shows you how to style a blockquote as a pullquote. ;o) > > I like that; and I can still change the title. > What about: > "How to style a blockquote as a pullquote using real images"

  • Lightroom 4 to be reinstalled after CPU-crash.

    Dear Sirs, as a hooby fotographer I hit it big ehen buying Lightroom 4 about 2 years ago, though download. I t has served me well and I thought moving to LR5 and the cloud was a bit overkill for my budget and needs. During july this summer my compute

  • Exported to external, taking space on internal?

    I exported a slideshow to my external drive, and when it was finished, it's not on my external but has taken up the space on my internal but it's not there. I've searched all through my internal and somehow I'm missing 4 gigs, the file is also not on