How to append a string from a file to a string???????????
hi there
the following code reads a line from a file,
while (true)
try
line = br.readLine();
catch (IOException e)
System.out.println("Error reading data file");
System.exit(1);
if (line == null) break;
st = new StringTokenizer(line, delimiterString);
n = st.countTokens();
if (first == 0) first = n;
if (n != first)
System.out.println("Data format error!");
System.exit(1);
how will i append the line to itself each time the loop runs? the line should contain all the lines in the file, not just a single line. thank you
You can make a StringBuffer object with the same scope as the line String and keep appending to the StringBuffer. You can use StringBuffer's toString() method to get a String back when you need it. You can also do this with a String instead of a StringBuffer using +=, but the String buffer is a lot more efficient.
StringBuffer wholeFile = new StringBuffer();
while (true)
try
line = br.readLine();
wholeFile.append(line); // or put this wherever it makes most sense
catch (IOException e)
System.out.println("Error reading data file");
System.exit(1);
if (line == null) break;
st = new StringTokenizer(line, delimiterString);
n = st.countTokens();
if (first == 0) first = n;
if (n != first)
System.out.println("Data format error!");
System.exit(1);
}
Similar Messages
-
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 Load the data from excel file(Extension is .CSV) into the temp.table
Hi
How to Load the data from excel file(Extension is .CSV) into the temporary table of oracle in Forms11g.
My Forms Version is - Forms [64 Bit] Version 11.1.2.0.0 (Production)
Kindly Suggest the Solution.
Regards,
SachinHello Sachin,
You can use the following metalink note:How to Read Data from an EXCEL Spreadsheet into a Form Using Webutil Client_OLE2 (Doc ID 813535.1) and modify it a little bit.
Instead of copy values into forms you can save them in your temporary table.
Kind regards,
Alex
If someone's helpful or correct please mark it accordingly. -
How to load the data from .csv file to oracle table???
Hi,
I am using oracle 10g , plsql developer. Can anyone help me in how to load the data from .csv file to oracle table. The table is already created with the required columns. The .csv file is having about 10lakh records. Is it possible to load 10lakh records. can any one please tell me how to proceed.
Thanks in advance981145 wrote:
Can you tell more about sql * loader??? how to know that utility is available for me or not??? I am using oracle 10g database and plsql developer???SQL*Loader is part of the Oracle client. If you have a developer installation you should normally have it on your client.
the command is
sqlldrType it and see if you have it installed.
Have a look also at the FAQ link posted by Marwin.
There are plenty of examples also on the web.
Regards.
Al -
How to load the data from excel file into temprory table in Forms 11g?
Hi
How to Load the data from excel file(Extension is .CSV) into the temporary table of oracle in Forms11g.
My Forms Version is - Forms [64 Bit] Version 11.1.2.0.0 (Production)
Kindly Suggest the Solution.
Regards,
SachinDeclare
v_full_filename varchar2(500);
v_server_path varchar2(2000);
v_separator VARCHAR2(1);
v_filename VARCHAR2(400);
filename VARCHAR2 (100);
v_stop_load varchar2 (2000);
v_rec_error_log varchar2(4000);
v_error_log varchar2(4000);
ctr NUMBER (12);
cols NUMBER (2);
btn number;
RES BOOLEAN;
application ole2.obj_type;
workbooks ole2.obj_type;
workbook ole2.obj_type;
worksheets ole2.obj_type;
worksheet ole2.obj_type;
cell ole2.obj_type;
cellType ole2.OBJ_TYPE;
args ole2.obj_type;
PROCEDURE olearg
IS
args ole2.obj_type;
BEGIN
args := ole2.create_arglist;
ole2.add_arg (args, ctr);
ole2.add_arg (args, cols);
cell := ole2.get_obj_property (worksheet, 'Cells', args);
ole2.destroy_arglist (args);
END;
BEGIN
v_full_filename := client_get_file_name(directory_name => null
,file_name => null
,file_filter => 'Excel files (*.xls)|*.xls|'
||'Excel files (*.xlsx)|*.xlsx|'
,message => 'Choose Excel file'
,dialog_type => null
,select_file => null
If v_full_filename is not null Then
v_separator := WEBUTIL_CLIENTINFO.Get_file_Separator ;
v_filename := v_separator||v_full_filename ;
:LOAD_FILE_NAME := substr(v_filename,instr(v_filename,v_separator,-1) + 1);
RES := Webutil_File_Transfer.Client_To_AS(v_full_filename,"server_path"||substr(v_filename,instr(v_filename,v_separator,-1) + 1));
--Begin load data from EXCEL
BEGIN
filename := v_server_path||substr(v_filename,instr(v_filename,v_separator,-1) + 1); -- to pick the file
application := ole2.create_obj ('Excel.Application');
ole2.set_property (application, 'Visible', 'false');
workbooks := ole2.get_obj_property (application, 'Workbooks');
args := ole2.create_arglist;
ole2.add_arg (args, filename); -- file path and name
workbook := ole2.get_obj_property(workbooks,'Open',args);
ole2.destroy_arglist (args);
args := ole2.create_arglist;
ole2.add_arg (args, 'Sheet1');
worksheet := ole2.get_obj_property (workbook, 'Worksheets', args);
ole2.destroy_arglist (args);
ctr := 2; --row number
cols := 1; -- column number
go_block('xxx');
FIRST_RECORD;
LOOP
--Column 1 VALUE --------------------------------------------------------------------
olearg;
v_stop_load := ole2.get_char_property (cell, 'Text'); --cell value of the argument
:item1 := v_stop_load;
cols := cols + 1;
--Column 2 VALUE --------------------------------------------------------------------
olearg;
:item2 := ole2.get_char_property (cell, 'Text'); --cell value of the argument
cols := cols + 1;
--<and so on>
ole2.invoke (application, 'Quit');
ole2.RELEASE_OBJ (cell);
ole2.RELEASE_OBJ (worksheet);
ole2.RELEASE_OBJ (worksheets);
ole2.RELEASE_OBJ (workbook);
ole2.RELEASE_OBJ (workbooks);
ole2.RELEASE_OBJ (application);
END;
--End load data from EXCELPlease mark it as answered if you helped. -
How to load the data from excel file into table in oracle using UTL_FI
How to load the data from excel file into table in oracle
and from table to excel file
using UTL_FILE package
Please give me some exampleThis is something i tried in oracle apex
http://avdeo.com/2008/05/21/uploading-excel-sheet-using-oracle-application-express-apex/
Regards,
CKLP -
How to create Inbound Idoc from XML file-Need help urgently
Hi,
can any one tell how to create inbound Idoc from XML file.
we have xml file in application server Ex. /usr/INT/SMS/PAYTEXT.xml' we want to generate inbound idoc from this file.we are successfully able to generate outbound XML file from outbound Idoc by using the XML port. But not able to generate idoc from XML file by using we19 or we16.
Please let me know the process to trigger inbound Idoc with out using XI and any other components.
Thanks in advance
Dora ReddyHi .. Did either of you get a result on this?
My question is the same really .. I am testing with WE19 and it seems SAP cannot accept an XML inbound file as standard.
I see lots of mention of using a Function Module.
Am I correct in saying therefore that ABAP development is required to create a program to run the FM and process the idoc?
Or is there something tht can be done with Standard SAP?
Thanks
Lee -
How to remove a folder from claud files
how to remove a folder from claud files?
Folder (and file) deletion is a two-part process. First you Archive the file from the Files page at https://creative.adobe.com/files, or by deleting it from the Creative Cloud Files folder on your computer. Then you Permanently Delete the folder from the Archive at https://creative.adobe.com/archive.
Help article: Creative Cloud Help | Manage and Sync files -
How to import a logo from flat file to SAP in SMARTFORM.
how to import a logo from flat file to SAP in SMARTFORM. i need to know whether TIFF format is used and also the full steps.
Thanks,Hi,
You can not directly use a logo from a file into a Smart form. First you will have to upload it to SAP. This has to be done only once. Once it is imported into SAP then you can use it in smart form. To import a logo to SAP, goto SE78. Open the tree under GRAPHICS. Select the file type and click on the Import (first button on the toolbar, just before delete button). Select the logo file and give it some appropriate name along with description. Select appropriate type of the image and click Continue. Your logo will be uploaded into SAP from a file. Now in your smartform, Create a Graphic Node, give the name of the logo along with other properties. In this way you can import a logo from a flat file into SAP and consequently in a smart form.
Reward points if the answer is helpful.
Regards,
Mukul -
How to Export multiple photos from pdf files?.
Good day.
How to Export multiple photos from pdf files?.
Thanks.Hello
how to reach from file menu ?.
Running Adobe reader 9 version 9.3.0
Thanks again. -
How to exclude schema name from exported files (PL SQL Developer)
Dear all,
Just one question: I am using PL SQL Developer. My goal is to export some data (as .sql and .dmp files) from one database and to import them into the another database (both databases have identical structure - test database and production, just different database names and names of schema. In order to make it possible, I need to exclude schema name from generated export file. I believe that it is possible to do it automatically by setting up parameters of PL SQL Developer. How?
Thank you in advance,
Kindest regards,
DraganaIn the meantime, I have found the answer on my previous question:
Actually, the initial idea (how to exclude schema name from exported files) was wrong. No need for any intervention.
Trick is: Schema name can be changed during the import of exported files (PL SQL Developer during import gives possibility: From User (old schema) To User (new schema) .
Hope that this will be useful info for others.
Dragana -
How to append a string whose content is XML file to the child of other XML?
Hi guys,
I have a question:
I obtain a string which is actually a response from HTTP servlet, and I want to append this string as child of another XML, how can I do it? Is there any method to convert string to XML node, opposite to the method "render_2_string"?
Thanks in advance
Message was edited by: Liying WangIf I understand your question correctly, this may be helpful.
types: begin of myStructure,
myNumber type n,
myChar type c,
end of myStructure.
Data:
IXML Type Ref To IF_IXML,
XMLDOC Type Ref To IF_IXML_DOCUMENT,
RC Type SY-SUBRC.
data rootNode type ref to if_ixml_element.
data newNode type ref to if_ixml_element.
data sourceString type string.
types
ixml = cl_ixml=>create( ).
xmlDoc = ixml->create_document( ).
rootNode = xmlDoc->create_element( 'RootElement' ).
setAttributesFromStructure( node = rootNode structure =
mystructure ).
newNode = xmlDoc->create_element( 'newNodeAdded' ).
if sourceString is not initial.
rc = newNode->IF_IXML_NODE~SET_VALUE( sourceString ).
endif.
add navigation graph entry
rc = rootNode->append_child( newNode ).
Quack -
How to append binary data to existing file in OSB
Hi,
I have an OSB project that I need for it to append binary data via ftp. Here's my current flow:
MFL binary output --> Replace $body with mfl binary output --> Publish to action (Business service that's configured to ftp binary data).
However, when the data is ftp'ed the following error is thrown:
URI = ftp://xxx:21/opt/home/zzz/logs
Request metadata =
<xml-fragment>
<tran:headers xsi:type="ftp:FtpRequestHeaders" xmlns:ftp="http://www.bea.com/wli/sb/transports/ftp" xmlns:tran="http://www.bea.com/wli/sb/transports" xmlns:xsi="h
ttp://www.w3.org/2001/XMLSchema-instance">
<ftp:fileName>11802_insert_oh_xfrmr.eai_data</ftp:fileName>
</tran:headers>
<tran:encoding xmlns:tran="http://www.bea.com/wli/sb/transports">utf-8</tran:encoding>
<ftp:isFilePath xmlns:ftp="http://www.bea.com/wli/sb/transports/ftp">false</ftp:isFilePath>
</xml-fragment>
Payload =
19266787^CLLL^C711791^CLLL^C^C1178213^CSingle Phase(1)^C63185066204^CA^CConstructed^C358880 NW 4 DR LK MONTAZA^C120/240^C09361^CN/A^CProposed Remove^CAerial^C45718100^C
Unknown^C^CNo^CNormal Closed^CClamp^CA^C1^C2-Cover^C19266796^CNo^CNo^C15^C^CYes^CYes^CYes^C13200Y/7620 X 22860Y/13200^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C
^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C19266641^Coh_fuse_switch^C63086930001^C4^CN31^CDD0613^C22.9^C63376474601^C8129580^CFalse^C4^COke
echobee^C43^C0^Cdefault^CYes^C
>
####<Nov 6, 2013 2:28:23 PM EST> <Error> <WliSbTransports> <goxsd1604> <osb_server1> <[ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'> <<
anonymous>> <BEA1-4B688443B66FA09FFE75> <d2b4601b2fffd9b7:6b9f2297:1422a857ee8:-8000-000000000000171b> <1383766103889> <BEA-381105> <Error occured for the service endpo
int: com.bea.wli.sb.transports.TransportException: Unable to open data connection. Message is Received error response (553) from FTP server [mpsd1] IP [10.111.19.32] po
rt [21] status [connected] upon executing command [stor opt/home/zzz/logs/11802_insert_oh_xfrmr.eai_data.a]
com.bea.wli.sb.transports.TransportException: Unable to open data connection. Message is Received error response (553) from FTP server [mpsd1] IP [10.111.19.32] port [2
1] status [connected] upon executing command [stor opt/home/icanadm/logs/11802_insert_oh_xfrmr.eai_data.a]
at com.bea.wli.sb.transports.ftp.connector.FTPTransportProvider.sendMessage(FTPTransportProvider.java:422)
From what I understand the error code 553 represents a bad file name. The file name that I'm supplying is 11802_insert_oh_xfrmr.eai_data but it appears that the name is changed to 11802_insert_oh_xfrmr.eai_data.a . So I did the obvious and changed the file several different ways (without the .eai_data extension, removed the numbers from the file name) but still no luck.
Any suggestions?
Thanks,
YusufThanks Eric.
I'm using the JCA FTP adapter instead and noticed it's appending the test generated data supplied by the OSB test console.
However, how can I ensure that the MFL output that I need to append will be placed on a new line?
Also, how should I map/assign the MFL binary output to the opaqueElement type base64Binary defined in the WSDL file below?
Once again here's a sample payload that I need to ensure will be presented on a new line:
19266787^CLLL^C711791^CLLL^C^C1178213^CSingle Phase(1)^C63185066204^CA^CConstructed^C358880 NW 4 DR LK MONTAZA^C120/240^C09361^CN/A^CProposed Remove^CAerial^C45718100^C
Unknown^C^CNo^CNormal Closed^CClamp^CA^C1^C2-Cover^C19266796^CNo^CNo^C15^C^CYes^CYes^CYes^C13200Y/7620 X 22860Y/13200^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C
^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C19266641^Coh_fuse_switch^C63086930001^C4^CN31^CDD0613^C22.9^C63376474601^C8129580^CFalse^C4^COke
echobee^C43^C0^Cdefault^CYes
Here's the WSDL file that gets generated for the FTP adapter:
<wsdl:definitions
name="PutGenericDevice"
targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/ftp/AMS/Project1/PutGenericDevice"
xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://xmlns.oracle.com/pcbpel/adapter/ftp/AMS/Project1/PutGenericDevice"
xmlns:opaque="http://xmlns.oracle.com/pcbpel/adapter/opaque/"
xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
>
<plt:partnerLinkType name="Put_plt" >
<plt:role name="Put_role" >
<plt:portType name="tns:Put_ptt" />
</plt:role>
</plt:partnerLinkType>
<wsdl:types>
<schema targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/opaque/"
xmlns="http://www.w3.org/2001/XMLSchema" >
<element name="opaqueElement" type="base64Binary"/>
</schema>
</wsdl:types>
<wsdl:message name="Put_msg">
<wsdl:part name="opaque" element="opaque:opaqueElement"/>
</wsdl:message>
<wsdl:portType name="Put_ptt">
<wsdl:operation name="Put">
<wsdl:input message="tns:Put_msg"/>
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>
Here's the JCA details:
<adapter-config name="PutGenericDevice" adapter="FTP Adapter" wsdlLocation="PutGenericDevice.wsdl" xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
<connection-factory location="eis/ftp/DssPut"/>
<endpoint-interaction portType="Put_ptt" operation="Put">
<interaction-spec className="oracle.tip.adapter.ftp.outbound.FTPInteractionSpec">
<property name="PhysicalDirectory" value="/opt/eai/ofmw/Oracle/Middleware_R7/logs"/>
<property name="FileType" value="binary"/>
<property name="Append" value="true"/>
<property name="FileNamingConvention" value="dummy.txt"/>
</interaction-spec>
</endpoint-interaction>
</adapter-config>
Thanks,
Yusuf -
How to append in an encoder created file
I'm using XMLEncoders and XMLDecoders for storage of java objects. Currently I've tried on simple data types only. But the problem is if I want to operate on the XMLEncoder created file from two different programs, then it is giving errors. In one program I'm executing
XMLEncoder e = new XMLEncoder(new BufferedOutputStream
(new FileOutputStream("polledobjects.xml")));
e.writeObject(...);
e.writeObject(...);
e.close();
and in another program I want to append to append a few more objects in the same polledobjects.xml, so I created another XML encoder object and opened the polledobjects.xml in append mode.
XMLEncoder e1 = new XMLEncoder(new BufferedOutputStream(new
FileOutputStream("polledobjects.xml",true)));
e1.writeObject(...);
e1.writeObject(...);
e1.close();
Now, Decoder works fine till the point it goes thru xml portion created by the first program, but as soon as it reached xml portion created by the second program, it gives the error->
java.lang.ArrayIndexOutOfBoundsException: 2
at java.beans.ObjectHandler.dequeueResult(XMLDecoder.java:272)
at java.beans.XMLDecoder.readObject(XMLDecoder.java:150)
at Convert.main(Convert.java:57)
XML file created is :-
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.4.2" class="java.beans.XMLDecoder">
<object class="Data_to_Poll">
<void property="active">
<boolean>true</boolean>
</void>
<void property="agent">
<string>192.9.200.151</string>
</void>
</object>
</java>
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.4.2" class="java.beans.XMLDecoder">
<object class="Data_to_Poll">
<void property="active">
<boolean>true</boolean>
</void>
<void property="agent">
<string>192.9.200.151</string>
</void>
</object>
</java>
I know it is giving problems b'cos it is encountering <?xml tag 2 times in the same xml document, but what should I do if I want to append in the same xml file and in the second program nothing more than filename is known...
plz. help me out....Well, Instead of writing different objects in the same stream.
e.writeObject(obj1);
e.writeObject(obj2);
First put them in some collection. for eg. a List or Set
Set set = new HashSet();
set.add(obj1);
set.add(obj2);
and then serialize the set e.writeObject(set);
Does this sound like a solution ? -
How can I read content from PDF file stored in Oracle 9i XMLDB
Hi Friends:
Now I have met one question that I don`t know how to read some String , for example "Hello", from the PDF file stored in the Oracle 9i XMLDB, I have stored that PDF file into the XMLDB now, any suggestions are appriciated . Thank you in advance.You may be able to do something with Oracle Text. The following shows how to get an HTML rendiditon of a binary document. I think you can also get plain text instead of HTML
set echo on
spool xfilesUtilties.log
connect sys/&1 as sysdba
grant ctxapp to &2
connect &2/&3
begin
ctxsys.ctx_ddl.create_policy(policy_name=>'XFILES_HTML_GENERATION', filter=>'ctxsys.auto_filter');
end;
create or replace package xfiles_internal_11010
authid definer
as
function renderAsHTML(sourceDoc BLOB) return CLOB;
end;
show errors
create or replace package body xfiles_internal_11010
as
function renderAsHTML(sourceDoc BLOB)
return CLOB
as
html_content CLOB;
begin
dbms_lob.createTemporary(html_content,true,DBMS_LOB.SESSION);
ctx_doc.policy_filter(policy_name => 'XFILES_HTML_GENERATION',
document => sourceDoc,
restab => html_content,
plaintext => false);
return html_content;
end;
end;
show errors
create or replace package xfiles_utilities_11010
authid current_user
as
HOME_FOLDER constant varchar2(700) := xdb_constants.HOME_FOLDER;
PUBLIC_FOLDER constant varchar2(700) := xdb_constants.PUBLIC_FOLDER;
function renderAsHTML(sourceFile VARCHAR2) return CLOB;
function transformToHTML(xmldoc XMLType, xslPath VARCHAR2) return CLOB;
end;
show errors
create or replace package body xfiles_utilities_11010
as
function renderAsHTML(sourceFile VARCHAR2)
return CLOB
as
begin
return xfiles_internal_11010.renderAsHTML(xdburitype(sourceFile).getBLOB());
end;
function transformToHTML(xmldoc XMLType, xslPath VARCHAR2)
return CLOB
as
html clob;
begin
select xmldoc.transform(xdburitype(xslPath).getXML()).getClobVal()
into HTML
from dual;
return html;
end;
end;
show errors
grant execute on xfiles_utilities_11010 to public
create or replace public synonym xfiles_utilities for xfiles_utilities_11010
quitMessage was edited by:
mdrake
Maybe you are looking for
-
Is there a way to see all your new mail from multiple accounts on one page?
I'm currently receiving emails from four different accounts on my iPhone. I love getting all my emails like this, but it would be even nicer if I didn't have to navigate between all the different accounts.
-
Unable to revert back to an old BIOS?
I updated my Neo Platinum's BIOS from 1.1 to 1.3 in attempts to resolve the temperature issue, but it only resulted in BSOD's when loading Windows XP. I reverted back to 1.1, and everything was fine again. I then tried the beta 1.45 BIOS, and got B
-
Solaris 10 panics during reboot after successful installation
hello, this is the 2nd time i'm trying to make solaris 10 x86 (latest dvd version) to run on my asus w1n laptop. /first i tried cd version in last december./ and again i'm not being successful. what happens is this: after (i guess successful) install
-
Titler program causes cs5 premium pro to crash
I was in the middle of a project using cs5 premium pro and using titler with no problems. There was a momentary power outage (don't know if this had anything to do with the problem) and computer rebooted without issue. Next day when I went to use t
-
Html attachement in ibot has garbage values
Hi all, we tried to schedule a report to save as html file in a local directory. we followed the below link [http://oraclebizint.wordpress.com/2007/12/17/oracle-bi-ee-101332-calling-java-scripts-and-java-classes-from-ibots/] it is saving the file suc