Reading files FASTLY
i have the code for reading n number of files which contains n number of lines.i want to read those files fastly.. and search a particular string from those files and i have to produce output....is there any other logic to read fasly..
i have pasted the following code below.
import java.io.*;
import java.lang.*;
public class file {
public static void main(String[] arg)throws IOException{
String filename = "E:\\SE\\textfiles";
File f1=new File(filename);
File[] f2=f1.listFiles();
for(int i=0;i<f2.length;i++)
FileInputStream is=new FileInputStream(f2);
if (is != null) {
InputStreamReader isr = new InputStreamReader(is);
BufferedReader reader = new BufferedReader(isr);
String text = "";
while ((text = reader.readLine()) != null) {
if(text.substring(0,4).equals("ATOM")){
System.out.println(text+"\n");
isr.close();
sesaravanan7 wrote:
i have planned to execute the whole process on client side itself.but i dont know how to do it....i am searching for that.This whole task seem to be ideal for my ReaderToWriterKMP class given in reply #12 of http://forum.java.sun.com/thread.jspa?threadID=769325&messageID=4385745 which will work as long as the client is a Java Applet or a WebStart application. Of course the OP will need to sign the jars.
Similar Messages
-
Adobe Reader X fast web view problem
Hi,
When I try to open a PDF with several pages from the web using Adobe Reader X, fast web view function seems not working while I could only view it after download of the whole file completed. Checked and confirmed that "Allow fast web view" selected in the Reader, as well as the PDF file being tested support such function. Here's my OS and software environment:
- Windows 7 Pro 64-bit with SP1
- Internet Explorer v8.0.7601.17514
- Adobe Reader X v10.0.1
I tried several scenario as below:
- Disable "Display PDF in browser", no improvement
- Uninstall Reader X and install Reader 9, test on the same PDF and fast web view working properly
- Uninstall Reader 9 and install Reader X again, same problem happen again
- Install Reader X on a freshly installed Windows XP with SP3, same problem appears
Does anyone experience the same issue? Or any ideas \ solutions? Many thanks.
Regards,
Maguyver F.Hi
Security Method: No Security
Printing: Allowed
Document Assembly: Not Allowed
Content Copying: Allowed
Content Copying for Accessibility: Allowed
Page Extraction: Not Allowed <-- Could this be the problem
Commenting: Not Allowed
Filling of form fields: Allowed
Signing: Allowed
Creation of template pages: Not Allowed
Thanks for the interest
Rudi -
How to open a large file faster?
Hi,
I am developing a website which will host some documents. Size of the docuemnts are between 1MB to 10MB ans they are PDF documents. I open the document in a new page based on some inout parameters.
I am using the following code. But it takes long time to get displayed. Is there any other way of reading and displaying the file faster? Is it possible to use buffer reader here and make it faster? Please help.
OpenFileStream display =new OpenFileStream();
String fileName =request.getParameter("fileName");
display.displayFile(request,response,fileName);The code which I sent is working. I do not know why you said it can not work.you call these methods
http://java.sun.com/j2se/1.4.2/docs/api/java/io/InputStream.html#read(byte[])
http://java.sun.com/j2se/1.4.2/docs/api/java/io/InputStream.html#available()
in this code int numOfBytes = fileInput.available();
byte byteArray[] = new byte[numOfBytes];
int totalBytes = reader.read(byteArray);In general its not guaranteed that fileInput.available() will return the number of bytes in the file. It returns how many bytes it can read before blocking. It says: "Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream"
try adding byte byteArray[] = new byte[numOfBytes];
if(numOfBytes!=new File(fileName).length()) {
System.out.println(fileName+" has not been read correctly");
}to your code to see if this is happening.
Now I tried using the following code. Will it be
faster than previous code? I don't see why it would be - have you tried running it and timing it?
I still think the only (possibly very small) performance benefit you can get here is to overlap the reading and writing phases - so that you start reading the file, and writing it to the output stream at the same time. -
Do you know some trick to move files faster. I have an external hard drive using Firewire hard drive and I am trying to move files to a USB 2.0 drive, but it is very slow.
I would say the speed is determined by the slowest link, which would be the USB drive and I don't think there is anything you can do about it unless the drive(s) are malfunctioning.
-
the Wifi storage options are interesting but it seems they only allow to read files from the device on the iPad but not transfer files to the storage device via WiFi.
I'm looking for a possibility to use the iPad for photography while traveling, without the access to a computer.
Shooting photo's in RAW format crates pretty big files that will fill up the iPad's memory pretty fast if you shoot a lot during a (let's say) month long trip.
my idea was to use load the photo's to the iPad so i could view them and sort out any bad ones. then copy them over to the storage device so i can continue using my CF cards for shooting. I have an image thank for copying the photo's directly to the HDD but it would be so sweet to be able to check them on the iPad before hand.
any suggestions?Check out pogo plug device, it allows you to upload camera roll via wifi.
-
HOW TO DELETE ADOBE READER FILE FROM ADOBE READER
HOW TO DELETE ADOBE READER FILE FROM ADOBE READER@ !@
Your question make no sense. What exactly are you trying to do?
-
Reading Files from an FTP location based on Timestamp
Hi,
I have a requirement of reading files from an FTP location. The files should be read in the order they were saved in the folder. Can someone tell me how to solve this?
Thanks,
RaviHi Arik,
Thanks for your reply. I tried doing what u said, but it isn't working. My requirement is to List the files in the folder using FTP adapter and get the file name with the least file stamp from the FTP adapter and pass the FileName dynamically to another FTP adapter which reads the file based on the FileName. When i tested after including the property (for listing the files) you mentioned, it is giving the following error (copied from flow trace):
<messages>
<input>
<Invoke_getFileListFTP_FileListing_InputVariable>
<part name="Empty" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<empty xmlns="http://xmlns.oracle.com/pcbpel/adapter/ftp/APP_SequentialFileTransfer/PRJ_SequentialFileTransfer/WS_GetFileList_FTP"/>
</part>
</Invoke_getFileListFTP_FileListing_InputVariable>
</input>
<fault>
<bpelFault>
<faultType>0</faultType>
<bindingFault xmlns="http://schemas.oracle.com/bpel/extension">
<part name="summary">
<summary>Exception occured when binding was invoked. Exception occured
during invocation of JCA binding: "JCA Binding execute of
Reference operation 'FileListing' failed due to: Exception
occured when binding was invoked. Exception occured during
invocation of JCA binding: "Could not instantiate
InteractionSpec
oracle.tip.adapter.ftp.outbound.FTPListInteractionSpec due
to: Cannot set JCA WSDL Property. Error while setting JCA
WSDL Property. Property setListSorter is not defined for
oracle.tip.adapter.ftp.outbound.FTPListInteractionSpec Please
verify the spelling of the property. ". The invoked JCA
adapter raised a resource exception. Please examine the above
error message carefully to determine a resolution. ". The
invoked JCA adapter raised a resource exception. Please
examine the above error message carefully to determine a
resolution.</summary>
</part>
<part name="detail">
<detail>Cannot set JCA WSDL Property. Error while setting JCA WSDL
Property. Property setListSorter is not defined for
oracle.tip.adapter.ftp.outbound.FTPListInteractionSpec Please
verify the spelling of the property.</detail>
</part>
<part name="code">
<code>null</code>
</part>
</bindingFault>
</bpelFault>
</fault>
<faultType>
<message>0</message>
</faultType>
</messages>
Thanks,
Ravi
Edited by: Ravi Santosh on Apr 24, 2012 11:02 PM -
Reading file from an external folder.
Iam tring to read an external file from the C:\ drive. Given below is the code.
DATA LV_XLS(100) TYPE C.
DATA LV_CONTENT TYPE XSTRING.
LV_XLS = 'C:\XML\Report.xls'
READ DATASET LV_XLS INTO LV_CONTENT.
But when i execute iam getting an error - FILE NOT FOUND. How do i read file from an external folder. My requirement is to strictly read from an external folder. Please help.
If this is not possible please advice as to how the file could be moved to the SAP root directory. Iam not able to locate the root.hi,
This is the code to read a excel file from the local system.
Read data set you are using in your code corresponds to files on application server thats the reason its throwing an error.
* Parameter variable declaration for browsing the file location *
PARAMETERS:
p_file TYPE ibipparms-path OBLIGATORY.
data:
it_text TYPE truxs_t_text_data .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
* DYNPRO_NUMBER = SYST-DYNNR
field_name = ' '
IMPORTING
file_name = p_file.
START-OF-SELECTION.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
* I_LINE_HEADER =
i_tab_raw_data = it_text
i_filename = p_file
TABLES
i_tab_converted_data = t_cust
EXCEPTIONS
conversion_failed = 1
OTHERS = 2
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
This is to read a text file from local system.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'D:\FILEINTERFACE\file.TXT'
* FILETYPE = 'ASC'
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = t_kna1
* EXCEPTIONS
* FILE_OPEN_ERROR = 1
* FILE_READ_ERROR = 2
* NO_BATCH = 3
* GUI_REFUSE_FILETRANSFER = 4
* INVALID_TYPE = 5
* NO_AUTHORITY = 6
* UNKNOWN_ERROR = 7
* BAD_DATA_FORMAT = 8
* HEADER_NOT_ALLOWED = 9
* SEPARATOR_NOT_ALLOWED = 10
* HEADER_TOO_LONG = 11
* UNKNOWN_DP_ERROR = 12
* ACCESS_DENIED = 13
* DP_OUT_OF_MEMORY = 14
* DISK_FULL = 15
* DP_TIMEOUT = 16
* OTHERS = 17
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
PS. In both of the above mentioned function modules make sure that the file structure is similar to the internal tables used.
Thanks
Sharath -
Hi,
Trying to read files from a dir on my site using a JSP and bean. I've tried nearly every option for the filepath I can think of and it doesn't seem to be finding the file...
Here's the bit:
String URL = "images\\wedding_photos\\";
File dir = new File(URL+aFile_to_add);
String[] files = dir.list();
It's working locally, but I obviously had to change the path from c://... to the above.
The full code is listed below in the addWedding Method
The method removes the .jpg from the file name and then writes the new file name to a database
Thanks for any insight.
Regards
Jim
public String addWedding(String aFile_to_add)
String feedback = "unset in scrubWedding";
try
String URL = "images\\wedding_photos\\";
Class.forName("org.gjt.mm.mysql.Driver");
java.sql.Connection connection = java.sql.DriverManager.getConnection("jdbc:mysql://localhost/rhwedd2_shop?user=**********&password=*******");
java.sql.Statement statement = connection.createStatement();
File dir = new File(URL+aFile_to_add);
String[] files = dir.list();
if (files == null)
feedback = "Sorry, couldn't find the file "+aFile_to_add+"...no files have been added.";
else
for (int i=0; i<files.length; i++)
// Get filename of file or directory
String filename = files;
String no_extension;
//convert string array element into a char array
char [] charsfilename = filename.toCharArray();
int newlength = charsfilename.length -4;
no_extension = String.valueOf(charsfilename,0,newlength);
filesAdded = filesAdded+", "+no_extension;
// Show the new file names in stack trace without extension
//System.out.println("String no_extension " + no_extension );
statement.executeUpdate("INSERT INTO items VALUES ('"+no_extension+"',5,'"+aFile_to_add+"')");
// write to table with item_id and weddingid
feedback = "The following files have been added..."+filesAdded;
if (statement != null )
statement.close();
if ( connection != null )
connection.close();
catch(Exception e)
feedback = "Into the catch";
e.printStackTrace(System.err) ;
return feedback;
}//end addWeddingString URL = "images\\wedding_photos\\";
File dir = new File(URL+aFile_to_add); ok, ok, I'll answer...
1) What gives you the impression that the relative directory "images\\..." exists (or, in other words, what makes you think your current directory is the parent of "images"? -
Unable to read file from application server
Hi guys,
I am reading file(could be any extension) from application server,but some time i am successfuly able to read file and sometime unable to read,why its happening .
my code is here
OPEN DATASET E_FILE FOR INPUT IN BINARY MODE . "
IF SY-SUBRC = 0.
DO .
READ DATASET E_FILE INTO GS_PDF_TAB.
IF SY-SUBRC = 0.
APPEND GS_PDF_TAB TO GT_PDF_TAB.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET E_FILE.
ENDIF.
Thanks
Ankur SharmaHi,
What actually happens? Do you get a short dump? Do you get a return code ne 0? Does it run fine but you get no data in your table?
We aren't mind-readers and can't help much without more information.
Try using transaction AL11 to see if you access the files you are trying to open.
Gareth. -
Uploading and reading file from application server
Hi
My problem is when am uploading a file to application server it is getting stored in
usr/sap/transyp1/prod/in directory
after that i want to read that file from application server to update database
when using below code it is showing some other directory in f4 help
DATA: lv_hostname TYPE msxxlist-name.
DATA: lv_server TYPE bank_dte_jc_servername.
PARAMETERS: p_file TYPE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'BANK_API_SYS_GET_CURR_SERVER'
IMPORTING
e_server = lv_server.
lv_hostname = lv_server.
CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
EXPORTING
dynpfield_filename = 'P_FILE'
dyname = sy-cprog
dynumb = '1000'
filetype = 'P'
location = 'A'
server = lv_hostname.
experts could you please help me out
Thanks & Regards
Nagesh.ParuchuriUser Transaction file. You will get all logical file path names.
used following fucntion module to read file name and use command open dataset to read the file.
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
CLIENT = SY-MANDT
LOGICAL_FILENAME = C_LOGICAL_FILENAME
OPERATING_SYSTEM = SY-OPSYS
PARAMETER_1 = P_IN_FILENAME
IMPORTING
FILE_NAME = P_OUT_FILENAME
EXCEPTIONS
FILE_NOT_FOUND = 1
OTHERS = 2.
OPEN DATASET P_OPEN_FILE ENCODING UTF-8 IN TEXT MODE FOR OUTPUT.
IF SY-SUBRC <> 0.
MESSAGE E000(38) WITH 'Error in Opening file: ' V_PHY_FILENAME.
ENDIF. -
Open Data Set Error while trying to read file from non SAP server
Hi all,
is it possible to read data from non-SAP application Sever?
I'm using OPEN DATASET p_filin FOR INPUT IN LEGACY TEXT MODE CODE PAGE '1504',
Where p_filin is other Windows server.Our applicition server is under Unix.Is it a problem?
I make test to read file from SAP application server and it was ok.So how to call other server?
Thanks!Hi,
Yes it is possible to read data from a non SAP server through the statement OPEN DATASET.
The important thing to check is that the SAP Server got enough access to the non SAP server so it can perform a reading/writing process depending on your needs.
You should contact your network administrator and BASIS to help you check the permissions. This can be pretty tricky, specially if the servers are in different domains.
Regards,
Gilberto Li -
How to combine both DAQ AI signal, write and read file in single VI
Hi
I am the new user of LabVIEW version 7.1 for testing automation application. I have to measure 33 signals ( mostly analog like temp, pressure, etc...) from NI USB 6210 DAQ system and write in master file for future verfication.From real data or from master file back up have to write one more file if only the signal reaches steady state , which will used for analysis and same signals to be read from this file parallely & make a waveform and/or table display format.
Pl. help me to shortout this problem
note: I have plan to ugrade labVIEW version 2011 shortly, so let me know doing parrel acquistion write and read file for data analysis in same VI in version 7.1......Parallel operations in LabVIEW are very simple. Just code it in parallel and it will work.
Try taking a look at some of the examples in the NI Example Finder (Help > Find Examples). There you will find example for writing to and reading from files, as well as data acquistion in parallel with other operations.
You might need a producer/consumer architecture is you are acquiring data very quickly.
Chris
Certified LabVIEW Architect
Certified TestStand Architect -
Error ORA-20003: Cannot read file/... in Cash Management?
Dear All.
I am having this Error in the Cash Management Module on the bank statement load process
Error ORA-20003: Cannot read file /software/d01/oracle/interface/finance/inbound/email.9Nemail.13111507.3445704.cnv.
How do I resolve this error.
Thank you.Hi Lucy,
The error is probably due to one of the reasons:
1. There is no file in the location: /software/d01/oracle/interface/finance/inbound/email.9Nemail.13111507.3445704.cnv.
2. No permission on the file respective file.
Please get the assistance from the DBA to check on this.
Thanks &
Best Regards, -
[Urgent] How to read files from different directories?
I am new to Java Programming, I would like to know how to read files from directories other than the current one? (example as follows)
ProjectDirectory
|--MainDirectory
|--MainProgram.java
|--SupplementDirectory
|--SupplementProgram.java
|--Pictures
|--Image.gif
What should I write in the MainProgram.java so that I can use the supplementProgram.java from MainProgram and read the Image.gif file from the MainProgram.java?
ThanksRun through the I/O tutorial here. It should get you up to speed on this sort of thing...
Maybe you are looking for
-
My mom shut of Siri in the restrictions, but then she turned it back on, the problem is no matter how many times i turn my phone on and off, it still has voice control. Will someone help me?
-
Moved to correct forum by moderator Hi all, We have a problem in script where we need to increase he main window size where it is being populated with items, when we increase the main window the footer is getting over written in main window,we need t
-
Hi, Folks. If any one knows receiver end settings, to receive flat file data(no of records). Please explain me receiver settings Regards, Robert
-
How can i find the location of an app from the search bar?
I need to delete an app on my ipad3. I know it's on there b/c I can find it in the search bar. But for the life of me, I can't find where the icon is, so I can delete it. The search bar doesn't tell me where on the pad it is. I have 10-11 pages of ap
-
Create a follow-on audit in SAP Audit Management
Hi, I am struggling with figuring out how to create a subsequent or follow-on audit in SAP Audit Management. I am aware of the "Subsequent audit required" check box on the evaluation screen of the Audit, but as far as I could tell from other people'