Read that file!

I am looking for a fast way to put all the data from a file into a string. By fast, I am looking for 1 megabyte in about 5 seconds or less. Is this possible, and how should i go about doing this?

gilroitto wrote:
1 Mb in 5 seconds sounds extremely slow. Normal FileInputStream and new String should give you 20 Mb/second on a not very impressive computer.
File f=...
FileInputStream fIn=new FileInputStream(f);
byte[] buff=new byte[f.length()];
fIn.read(buff);
String data=new String(buff,encoding);
This is not guaranteed to work since the InputStream.read() method does not guarantee to read all the bytes. If one is not going to use a standard library then one should wrap the input stream in a DataInputStream and use the readFully() method.
Also f.length() return a long so it has to be cast to an int to be usable in defining the length of the buffer.

Similar Messages

  • My file has insert command and i want to read that file line by line in sql

    myfile.txt
    insert into emp values(100,200,"sumedh",11);
    insert into emp values(101,200,"amit",11);
    insert into emp values(102,200,"sam",11);
    insert into emp values(103,200,"ram",11);
    insert into emp values(104,200,"stev",11);
    I want to read this file line by line and enter this value in emp table.

    Why did you begin this thread in security.
    just like
    sqlplus <schema_owner>/<password>@<your_sid> @<path_to/myfile.txt>

  • Upload a txt file,read that file,display po details using BAPI

    hi GURUS,
    CL_GUI_FRONTEND_SERVICES=>gui_upload to retrieve the file (upload the file).
    HOW TO USE THIS??? GV MORE DETAILS PLEASE...I WANT TO read TEST PO DATA.txt file Can you give me example how the test data( Header data and Item level data is used to fill the test PO data.txt file )
    Do i need to Use OPEN DATASET
    CLOSE dATASET command?
    how????
    points will be rewarded
    thanks

    Hi Avik,
    using  CL_GUI_FRONTEND_SERVICES=>gui_upload in a program.
    There are sample programs in the following link
    http://wiki.ittoolbox.com/index.php/Upload_and_download_SAP_transport_request
    Award points if useful
    Thanks,
    Ravee...

  • How to set password for a zip file and should be checked when reading that

    Hi friends,
    how to set password for a zip file and should be checked when reading that file???
    thanks.
    Praveen Reddy.J

    Heyy man, i think, u did not get my problem.
    all i have to do is:
    i have to create a zip file, and we should secure it with password when creating. and whenever the user wants to open that zip file he should provide correct passowrd otherwise he could not read that file. So, we should check for that also.
    Tanks for reply.

  • How to read .mdb file from shared folder

    Hi All,
    In one of my local computer I have a shared folder and within the folder I have a .mdb file. Now I am trying to read that file from MII. I have tried with Get_File_List action block. I am providing the following information to Get_File_List
    Folder :
    <Computer Name>\<Shared Folder Name>
    Mask: .mdb
    But in return of Get_File_List, I am not getting any file related information. It is only providing like below
    <Rowsets>
    <Rowset>
    <Columns>
    <Column Description="Name" MaxRange="0" MinRange="0" Name="Name" SQLDataType="1" SourceColumn="Name"/>
    <Column Description="Date" MaxRange="0" MinRange="0" Name="Date" SQLDataType="93" SourceColumn="Date"/>
    <Column Description="Size" MaxRange="100" MinRange="0" Name="Size" SQLDataType="4" SourceColumn="Size"/>
    <Column Description="LastWriteDate" MaxRange="0" MinRange="0" Name="LastWriteDate" SQLDataType="93" SourceColumn="LastWriteDate"/>
    <Column Description="ReadOnly" MaxRange="1" MinRange="0" Name="ReadOnly" SQLDataType="4" SourceColumn="ReadOnly"/>
    <Column Description="FullPath" MaxRange="0" MinRange="0" Name="FullPath" SQLDataType="1" SourceColumn="FullPath"/>
    </Columns>
    </Rowset>
    </Rowsets>
    Can anybody suggest me how to achieve it.
    Thanks in advance
    Chandan

    Hi Chandan,
    Specify the mask as *.mdb and try.
    Thanks,
    Dipankar

  • Reading of File from legacy system into SAP Application Server using SAP XI

    Hi All,
      I have a file in <b>Legacy System with Exchange rates information data</b> i have to read that file using SAP XI process and put that file in SAP Application Server in SAP Specific Format and latter i have to use program RFTBFF00 to upload the file in the Application Server into SAP Tables.
      Can anybody tell me how can i do this with some example of same scenario.
      It would be better if anybody provides code example as i am new to SAP XI.
    Thanks in advance.
    Warm Regards,
    Rayeez.

    Hi Shaik,
    You need the access to the file system of ur legacy application and then you can follow this link for the required ifnormation
    File & Header
    Regards
    Vishnu

  • Read a file at a fixed time of day using PS in OSB

    I have a proxy service which read a file, now I want to read that file at a fixed time in a day(suppose 12pm every day).
    How do I make the JCA file/proxy configuration?
    Pls suggest!

    Re: How to implement in OSB: Scheduling, Timers and Custom properties
    Regards,
    Anuj

  • Reading XML file having various foreign languages from web application.

    Greeting..
    I'm dealing with a so-called serious problem where-in:
    I've to read one of the configuration files(XML files) having values in different foreign languages (like Chinese, Japanese, Arabic etc). I've to read that file contents, in as it is form, in such a way that user can read / change the data from the web application.
    I'm showing the XML file inside the TextArea (the HTML <textarea> tag. While reading this file, it got converted to junk values instead of actual ones. While saving this file it changes those original values to junk in file as well.
    I'm using SAX parser with DefaultHandler.
    Better suggestions are welcome.
    Thanks in advance
    Regards

    rikslovein wrote:
    Better suggestions are welcome.You have a number of places where data corruption could occur. You have not yet identified where it occurs. When you know where it occurs it would be much easier to determine a solution.
    Do NOT display the characters to determine the problem. Instead take a small sample and print the numeric values. And do that at each stage/layer until they do not match.

  • Is is possible to read a file while writing the same file at time in java?

    Hi ,
    I am reading a MSAccess file (mdb) from one location to another location .but the source file is an online database which will chage regularly .so while reading that file i am getting error like
    FileNotFoundException.
    java.io.FileNotFoundException: c:\Msaccess\db2.mdb (The process cannot access the file because it is being used by another
    s)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:106)
    at read.main(read.java:16)

    alphabet soup,
    Yes, windows helpfully prevents two processes from accessing a file simultaneously. Operating Systems on the other hand uniformly support it.
    Which probably doesn't help you very much, as I imagine that you can't just up and change the source machine over to *nix, but there you have it.
    You'll just have to close the program which has the database open, copy the database, and restart the program which uses the database.
    keith.
    Message was edited by: corlettk

  • Reading/monitoring file on each update by using java code

    Hello, Thanks for help in advance..
    I want to read a log file automatically on each time when log file get update . Actually i am reading that file one time but i have to read that file when log is added to that file.
    Thanks

    File change notification is not supported on all os yet.
    So I do not think it is available in java. You may have
    to write in C/C++ code for os which supports this feature.
    Or use file monitoring tools.

  • How to read a file which as restricted access

    Hi all.
    Lets say I have two users User1 and User2
    I have created a servlet which needs to read a file.
    Lets say the owner of the file is User1.
    So User2 cannot access this file.
    This is on windows platform.
    The problem is that the Servlet cannot know owner of its user.
    Servlet run's as anonymous, so the user as to enter his userName and Password.
    This is fine with me.
    But after this how do I use this to read that file.
    I have no clue on how to use this information to read this file.
    Examples if any will be very helpful.
    Thanks for your help in advance.

    Well, you'd hardly write a servlet that can access any file on your server, not exactly good security. Rather it needs to be confined to specific files or, at least, specific directories. The server can't change it's user identity, so it needs access to all files, but it's easy enough for the serlvet to have some mapping which tells it which files may be server to which users.

  • ODI and Essbase in different server to read the file error

    Hi,
    I have ODI and Essbase installed in different server.
    I have created an interface to execute a calc script on top of an essbase cube. I kept the Caclscript.csc file in one folder in ODI server and provide the path
    EXTRACTION_QUERY_FILE parameter is the path of the .csc file i placed in ODI server. it executed successfully to generate the extract file using the calc script in the specified path on Essbase server.
    Now i want to read that file and load it to a relational table so map the network drive from ODI server to Essbase server where the file has been generated and provided the EXTRACT_DATA_FILE_IN_CALC_SCRIPT parameter as the Network drive path but ODI is unable to read the file.
    any other option to read the file reside in essbase server and load it to relational table.
    com.hyperion.odi.essbase.ODIEssbaseException: com.hyperion.odi.essbase.ODIEssbaseException: Error occured while reading the data file produced by calculation script.
    -KP

    I would install an ODIAgent on the Essabse server and use this agent when running this particular operation

  • HOW TO READ A FILE AT A PERTICULAR TIME INTERVAL IN ORACLE ?

    Hi friends,
    There is a system in Cobol . It writes a file in every 20
    minuits. I want to read that file and take the data into my
    database. How do I do it in every 20 minuits ? Please help me.
    With advance thanx
    Feroz
    null

    LaRisa_S wrote:
    To transfer files manually (Graziano, I think you were asking about this), you can use Measurement and Automation Explorer, right-click the target under Remote Systems, and select Transfer. This will bring up an FTP window.
    Hi!
       Actually, I have no problems in transferring files manually, there're plenty of ways... I prefer using windows FTP client, sometimes I use command line client, sometimes NI's one.  What I was asking was enabling file server on cFP.  In product page, I can see that cFP has web server and file server.  No problem with web server, it's well known, but I didn't find anything for enabling file server!
       To keep it simple, for file server capability I mean the possibility of directly navigate cFP file system from my PC, without using FTP, just like networked PCs on a LAN with SMB protocol.
       Thanks
    graziano

  • How to read binary file in Matlab

    "Hello all!
    Labview 7.0 has an example "Cont Acq to File (binary).vi" log the PCI 6014 card and writes the data to a binary file. How can I read that
    file in Matlab(6.5.0... R13)? Does anyone have a solution for this?

    Hello,
    Basically you can do it by saving the data in a file in MATLAB and reading it directly from LabVIEW, or vice versa. In MATLAB , the command "save" allows you to save the data in binary format (*.mat) or ASCII format. You also have an option of saving it in ASCII format using a tab delimiter between data points.
    There is a knowledge base which talks in detail about how to share data in between labview and matlab Import data from labview to Matlab and vice versa.
    Hope this helps. If not, please feel free to ask more questions.
    Good luck and have a great day!
    Koninika
    National Instruments

  • How to read Sool file

    hi all
    can any1 tell me how should i read spool file
    i want to read tht spool and then send it to person automatically
    i can read that by sp01 but how to read that file in flat file or direcly send .
    Jimmy

    Jimmy,
    Basically you need to work with Basis peple in the transaction SCOTT.
    One FM you can use for sending email is SO_NEW_DOCUMENT_SEND_API1
    See the blog on this : /people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface
    Regards,
    Hari
    Thanks for the points..
    Message was edited by: Hari Kiran Y

Maybe you are looking for

  • Unicode in Oracle 8i and Oracle XE

    I'm developing a program to read database objects and data of Oracle Database from Oracle 8.1.7 and store everything as XML files and then read these XML file on different computer and built the same database on Oracle XE and import the data in to it

  • HT3235 HDMI to VGA Adapter

    Just checking if anyone can suggest what adapter would be suitable for HDMI to VGA Adapter, I'd love to connect two old HDMI to VGA monitor displays if possible as I have spare monitors and could use the facility.

  • IChat video impossible yet Skype Video possible

    It has been quite some time since I was able to have a video chat with iChat/iSight . With the new Skype Video Beta I have good video conferencing . At least I now know it is not a bandwidth problem . But why does iChat Video prove totally impossible

  • Aggregate on logical column

    Hi: I was testing two column, ID and Value like this: ID   Value 1     -2 2     -1 2      2 and the aggregate type for <b>Value</b> is Sum. So in the report, it will looks like: ID   Value 1     -2 2      1 It's OK. Then I define a logical column, <b

  • ATG 11 migration with JbossEAP6.1

    Hi, I am working on migration from ATG 10.2 to ATG11. Application is working fine with ATG10.2 with JbossEAP5.1. Config path is loading three times in log file and getting errors following way. 10:51:41,702 ERROR [stderr] (ServerService Thread Pool -