What is the best way to read in a file?

i'm currently doing it like this:
Vector inVector = new Vector();
try
File file = new File( "C:/1jkiesel/testAgent/Customers.txt" );
BufferedReader in = new BufferedReader( new FileReader( file ) );
String str;
while( ( str = in.readLine() ) != null )
inVector.add( str );
in.close();
catch( IOException e )
e.printStackTrace();
is there a better way? especially th full file path thing...

I did a search in the formums for
"best practice read file"
there were too many results so it was not very helpful
I think that the best practice is to look at the "read" methods for
each stream super class and decide which one is best for the particular
application you have.
I ask a follow up question:
Is there a web page where we can find some comparisons of the various methods? Comparisons like speed, size, exception handling?
hope this helps

Similar Messages

  • 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 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

  • What's the best way to read JSON data?

    Hi all;
    What is the best way to read in JSON data? And is the best way to use it once read in to turn it into XML and apply XPath?
    thanks - dave

    jtahlborn wrote:
    without having a better understanding of what your definition of "use it" is, this question is essentially unanswerable. Jackson is a fairly popular library for translating json to/from java objects. the json website provides a very basic library for parsing to/from xml. which one is the "best" depends on what you want to do with it.Good point. We have a reporting product ([www.windward.net|http://www.windward.net]) and we've had a number of people ask us for JSON support. But how complex the data is and what they want to pull is all over the place. The one thing that's commin is they generally want to pull down the JSON data, and then put specific items from that in the report.
    XML/XPath struck me as a good way to do this for a couple of reasons. First it seems to map well to the JSON data layout. Second it provides a known query language. Third, we have a really good XPath wizard and we could then use it for JSON also.
    ??? - thanks - dave

  • This community is great -- very helpful. What is the best way to read "word" docs on my brand new iPad 2? Is there an app for that?

    This community is great -- very helpful. What is the best way to read "word" docs on my brand new iPad 2? Is there an app for that?

    If you're just reading them from email attachments, you can just open it to "view" the document.
    However, if you wish to do editing and work, you'll need an application. I use Documents to Go, but there are other versions that people are happy with - do a search in the App store for "office suite" or "word processing".
    The next challenge is getting docs back and forth. Doc2Go and others have their own ways to physically sync docs when connected to a computer; you can also email changed/revised/new documents from the iPad to yourself. However, I use a "cloud service" called DropBox that stores docs in the cloud (so I can get to them anywhere) - I paid for the Premium version of Docs2Go to allow that kind of syncing.

  • What is the best way to keep my personal files stored in iCloud separate from my work-related files?

    What is the best way to keep my personal files stored in iCloud separate from my work-related files? It seems that I'm not allowed to link my iPad mini and my work iMac using two different accounts, so I'm wondering how to make my single personal account work for both, while keeping personal vs work files reasonably separated.
    Thanks for any suggestions.

    Is it possible for you to upgrade your account to iCloud Drive? That would mean, all Macs upgraded to Yosemite, and all mobile devices to iOS8?
    See:  iCloud Drive FAQ and iCloud: About using iWork for iOS and iCloud
    In iCloud Drive you could create two separate custom folders, one for work documents and one for private documents and organize your documents there.  Don't use the app specific folders (Keynote, Pages, Numbers, ...) , because you can only create one level of folders inside these folders.

  • What is the best way of reading a browser cookie and writing to sessionbean

    Hi,
    So far I have happily written a cookie in the visting browser and happily can display with a browser using a servlet println etc
    But what is the best way to take that value and put it into say getSessionBean1().setCookieValue("Cookievalue");
    I was thinking on the lines of calling a forward from the servlet "nexpage?cookievalue=stringetc".... or is there some nicer way?
    Thanks
    James

    In the page I simply referenced the facescontext directly... no need for a custom servlet.
    public void createcookie() {
    FacesContext fc = FacesContext.getCurrentInstance();
    HttpServletResponse resp = (HttpServletResponse)fc.getExternalContext().getResponse();
    Cookie userCookie = new Cookie("cookiename", "cookievalue");
    userCookie.setMaxAge(-1);
    userCookie.setMaxAge(3600);
    resp.addCookie(userCookie);
    return null;
    public String readcookie() {
    FacesContext fc = FacesContext.getCurrentInstance();
    ExternalContext ec = fc.getExternalContext();
    Map cookiemap = ec.getRequestCookieMap();
    if (cookiemap != null) {
    Cookie cookie = (Cookie) cookiemap.get("cookievalue");
    return cookievalue;
    For reference I could not get getCookies() method of HttpServletRequest to work.. it would only return JSESSIONID.

  • What is the best way to integrate a sound file (mp3) into a PDF?

    I saw that its possible to do it by Tools->Multimedia->Sound. This works fine on a computer but not a tablet. So what is the right way to embed a sound file into a PDF of maybe by Indesign? What i want is that people can easily open a document (PDF) on a tablet and when they click on a (play)icon that they hear a sound file. The best thing is that they can stop or put it on pause.

    I think this functionality relies on Flash, so it's not likely it's going
    to work on mobile devices, certainly not on iOS ones.

  • In Oracle Forms 10g, what is the best approach in read an excel file (csv)?

    Hi All!
    Could someone please advise me on what is the best way for an oracle form reading and extracting data from an excel spreadsheet (csv) that is located in the local drive directory.
    Someone had already advised me to use TEXT_IO function or use a javabean through the Implementation Class property.
    I'd really appreciate it if someone can give me insights.
    Thanks! beeals

    Other approach to load a CSV file, you can use EXTERNAL TABLES. SQL Reference manual has examples.
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7002.htm#i2095331
    [urlhttp://www.astral-consultancy.co.uk/cgi-bin/hunbug/doco.cgi?11210] simple example of external tables loading data into oracle
    or here
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:68212348056
    Regards
    Ros
    Message was edited by:
    Rosario Vigilante

  • What is the best way to send multiple pdf files to my ipad

    what is the best way or app to send multiple pdf files to my ipad, so that I can then combine them into one folder

    I have the app Readdle Docs. It allows you to move PDF files to your device and to move them around on your device. Might check it out. ( I think there's an iPad version of the app, but I have the iPhone version and it works, just not as pretty)
    THere's also Goodreader, but I don't have experience with it to know if it has folder abilities.

  • What is the best way to export/share GarageBand files with a non-mac user?

    I have some GB2 files, too big to email, that I want a client to hear and give direction. then I can make the changes and re-export them for him to hear again. What is the best way to do this? IMac seems to be forthcoming about sharing pictures and IMovies but not music files, for understandable reasons. Thanks.
    BB

    Here's one way, but be sure you understand the privacy policy!

  • What is the best way to include an xml file in JSP?

    I have a jsp page that I need to include an xml file. The xml file
              uses an xsl to render the file. What is the best way to include the
              xml file and still maintain the structure of the style sheet?
              Thanks
              Jennifer
              

              The best way is using the tag lib. If you cannot, but you can use JAXP, you can
              try
              javax.xml.transform.Transformer.transform(Source xmlSource,
              Result outputTarget)
              throws TransformerException
              You construct the transformer with you xsl, use you xml file or DOM to form xmlSource,
              and use JSPWriter "out" to form outputTarget (StreamResult). But if your JSP page
              generates the xml itself, tag lib is the only way.
              [email protected] (Jennifer) wrote:
              >[email protected] (Jennifer) wrote in message news:<[email protected]>...
              >> I have a jsp page that I need to include an xml file. The xml file
              >> uses an xsl to render the file. What is the best way to include the
              >> xml file and still maintain the structure of the style sheet?
              >>
              >> Thanks
              >>
              >> Jennifer
              >
              >Or is there a way to parse the xml file with the jsp page to display
              >the information. I cannot use the Java Standard Tag Libraries as the
              >version of iplanet we are running does not support the JSTL
              >
              >Thanks
              >
              >Jennifer
              

  • What is the best way to save an ai file so it can be opened in corel draw

    I have an ai file that needs to be opened in corel draw by a client. It needs to remain editable all paths and colors ect.
    Whats the best way to save it so it can be.
    yes I know corel is not as good as Illustrator but its what they have.

    Moving files back and forth between Adobe Illustrator and CorelDRAW is tricky. There's quite a bit more to it than knowing what version of CorelDRAW the client is using. If the artwork is fairly simple then there shouldn't be any problem with transferring the artwork into CorelDRAW. If the artwork has gradients, transparency effects, a lot of clipping masks, etc. then it's going to be a lot more dicey getting it to import into CorelDRAW properly. In addition to the .AI file you provide, you should give the client a PDF they can view in Adobe Reader or Acrobat so they can proof how the artwork is really supposed to look.
    I use Adobe Illustrator CC and CorelDRAW X6 in my work. I've used both applications for over 20 years. I don't consider either application better than the other. They both have their own unique strengths and weaknesses. I'll do a good bit of creative work within CorelDRAW to use certain features Illustrator either lacks or just doesn't do as well. Or I may need to design a really big project at full scale and Corel has a much bigger art board than Illustrator. Most of the time I move a lot of the stuff I created in CorelDRAW over to Illustrator for further refinement or moving it into Photoshop as paths or smart objects or just getting it ready to print (I don't like Corel's color engine even though it has improved in recent years).
    Like others have said, you need to know the basics of what the user has -mainly which version of CorelDRAW. The newer versions like the one I'm using can open Illustrator CS5 files. For older versions, you may have to save down to CS2 or even really old versions like Illustrator 8.
    CorelDRAW will not support certain Illustrator-dependent effects. For instance, if you apply a gradient to an object outline it will be lost when opened in CorelDRAW. A lot of other effects won't be maintained when opened in Corel unless they are flattened/expanded. Some effects may even have to be rasterized, and that can create other issues. Out of effects that are maintained, some may have to be adjusted. CorelDRAW and Adobe Illustrator handle things like gradient fills differently and don't understand how to portray gradients from their rival application accurately. Some nice fill that was created in CorelDRAW may have to be tweaked or completely rebuilt when opened in Illustrator.
    I get a lot of customer files in CorelDRAW and also a lot in Illustrator. That reason alone makes it necessary for me to have both CorelDRAW and Adobe Illustrator running on my computer.

  • What is the best way to reduce a .mov file size

    I had a music DVD that I converted to a .mov so that I could cut and paste in QT pro which i have done.
    Now I have a .mov file that is 46 gigabits in size and I want to reduce it considerably without ruining the quality of sound or visual.
    Whats the best way to do this.
    Thanks

    punt

  • WHAT IS THE BEST WAY TO CREATE AN XSD FILE (TO BE USED BY SOAP ADAPTER)

    Dear friends
    I have a simple scenario.
    OUTBOUND DATA  -->  SOAP ADAPTER  --> ( XI )  -->  RFC ADAPTER  --> INBOUND DATA
    The XML file that I got from mapping area of IR (Design) is as follows
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:MT_NAME_SOURCE xmlns:ns0="http://test3.com">
       <FIRSTNAME>DAVE</FIRSTNAME>
       <LASTNAME>SMITH</LASTNAME>
    </ns0:MT_NAME_SOURCE>
    If you notice, there are only 2 fields.
    I need to create an XSD file and import it as an external object, which I can use for SOAP Adapter.
    Which is the best way to create it.
    Also, I need to know if there is any step by step of sending a message from XML SPY. I have downloaded this software, but am not able to undertand how to use this.
    Hope to hear from any experts on this forum.
    Thanks in advance
    Ram

    Hi Ram,
    See the below blog..
    It shows how to send SOAP message using XML Spy.
    It also shows how to generate wsdl.
    /people/siva.maranani/blog/2005/09/03/invoke-webservices-using-sapxi
    Regards,
    Sumit

Maybe you are looking for