Converting fixed-record length file to XML
Hello all
I am trying to convert a fixed length flat file to XML.
I believe the only required information for such a coversion is- the element or field names, their data types, and the fixed length of each field.
I do not want to generate a xsl document by hand. Just looking if there are any open source tools which can help me out here.
Let me know if you guys have done this before.
Thanks
Mahesh :)
It all depends on the fixed length file format and the amount of money you are willing to spend. From what I can tell there's not much in the way of free tools for converting stuff like this. It's just not very sexy.
Similar Messages
-
How to load unicode data files with fixed records lengths?
Hi!
To load unicode data files with fixed records lengths (in terms of charachters and not of bytes!) using SQL*Loader manually, I found two ways:
Alternative 1: one record per row
SQL*Loader control file example (without POSITION, since POSITION always refers to bytes!)<br>
LOAD DATA
CHARACTERSET UTF8
LENGTH SEMANTICS CHAR
INFILE unicode.dat
INTO TABLE STG_UNICODE
TRUNCATE
A CHAR(2) ,
B CHAR(6) ,
C CHAR(2) ,
D CHAR(1) ,
E CHAR(4)
) Datafile:
001111112234444
01NormalDExZWEI
02ÄÜÖßêÊûÛxöööö
03ÄÜÖßêÊûÛxöööö
04üüüüüüÖÄxµôÔµ Alternative2: variable length records
LOAD DATA
CHARACTERSET UTF8
LENGTH SEMANTICS CHAR
INFILE unicode_var.dat "VAR 4"
INTO TABLE STG_UNICODE
TRUNCATE
A CHAR(2) ,
B CHAR(6) ,
C CHAR(2) ,
D CHAR(1) ,
E CHAR(4)
) Datafile:
001501NormalDExZWEI002702ÄÜÖßêÊûÛxöööö002604üuüüüüÖÄxµôÔµ Problems
Implementing these two alternatives in OWB, I encounter the following problems:
* How to specify LENGTH SEMANTICS CHAR?
* How to suppress the POSITION definition?
* How to define a flat file with variable length and how to specify the number of bytes containing the length definition?
Or is there another way that can be implemented using OWB?
Any help is appreciated!
Thanks,
Carsten.Hi Carsten
If you need to support the LENGTH SEMANTICS CHAR clause in an external table then one option is to use the unbound external table and capture the access parameters manually. To create an unbound external table you can skip the selection of a base file in the external table wizard. Then when the external table is edited you will get an Access Parameters tab where you can define the parameters. In 11gR2 the File to Oracle external table can also add this clause via an option.
Cheers
David -
Hi,
Fixed length file to xml files.
i have to generate 2 xml files based on a field in the incoming file. structures of both xml files are same.
I want to know how many target data type ,target msg interfaces have to be created?
Thanks.Ok got you. Best thing would be to use a simple OS command copy in your receiver communication channel. So do one mapping and generate one file and then use the OS command in receiver comm. channel after message processing then it should work for you.
Regards,
---Satish -
Fixed record length with GUI_DOWNLOAD
Hi All,
In our current system we set global variables GLOBAL_FIXLEN_* by calling form SET_FIXLEN(SAPLGRAP). This allows us to create ASCII download files using function module WS_DOWNLOAD that have a fixed record length of 160 as required by the bank.
We are now going to a unicode system and WS_DOWNLOAD is being replaced by GUI_DOWNLOAD. How can I continue to create a fixed record length of 160 using this function module? I cannot find any similar GLOBAL_FIXLEN* variables in GUI_DOWNLOAD.
Thanks in advance for suggestions,
KirstenHi,
Kirsten,
I find form "set_trail_blanks" also not available in GUI_DOWNLOAD.
FYI
aRs -
Issue in FCC paramenter in Fixed Filed Length file at reciver side
Hi,
I am doing IDOC to File interface. In that at receiver side I am sending file in Fixed Field Length Format.
Receiver File Message structure is as fallows.
Recordset
--Control
CTID
CTGUI
.... Control Fields
--Header
AHID
AHGUI
....Header Fields
--Detail
ADID
ADGUI
... Detail Fields
--Notes
INID
INGUI
...Notes Field
We want output File format in such a way that each Control, Header, Detail & Notes records should come on different line.
I am using following paramater in File Content conversion:
Recordset Structure* = Control,Header,Detail,Notes
Control.fieldFixedLengths = control field lengths
Header.fieldFixedLengths = header field lengths
Detail.fieldFixedLengths = detail field lengths
Notes.fieldFixedLengths = Notes field lengths
ignoreRecordsetName = true
But the problem is I am getting all records in same line in file.
Any help on this issue will be appreciated.
Regards,
Prashant KudtarkarHi Suraj,
You are right. When I open that file in notepad I am getting boxes at end of each record and all records are coming in same line but when I open that file in XL or wordpad I am getting each record on new line.
I am using following paramater in File Content conversion:
Recordset Structure* = Control,Header,Detail,Notes
Control.fieldFixedLengths = control field lengths
Header.fieldFixedLengths = header field lengths
Detail.fieldFixedLengths = detail field lengths
Notes.fieldFixedLengths = Notes field lengths
ignoreRecordsetName = true
Thanks and regards,
Prashant Kudtarkar -
Cannot process a Fixed Field Length file using the File Adapter (Sender)
Hi -
I have checked throughout these posts and blogs but I still have not been able to find a solution to my issue. When using the File Adapter (Sender) I get a Conversion initialization failed with "xml.keyfieldName", no value found. Why would I require a key field when I am using fixed field lenghts? The file is comprised of 2 structures - 1 header and multiple details (see below). There are no key fields in the flat file that I would be able to use. Any suggestions?
011000390 Customer Americas 20080605164317 000000000000000800000008000000000016000000
12345678 100500 100500 Supplier 1 0000000000030000002008040400
12345678 100501 100501 Supplier 2 0000000000052000002008042100
The File Adapter is configured as follows:
Document Name = Rfchke00
Document Namespace = 'my namespace'
Recordset Name = Rfchke00
Recordset Structure = Dtachkh,1,Dtachkp,*
Recordset Sequence = Ascending
Recordsets per Message = 1
Key Field Type = String (Case-Sensitive)
Dtachkh.fieldFixedLengths = 15,25,8,6,1,8,8,8,15,3,31
Dtachkh.fieldNames = F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11
Dtachkh.processFieldNames = fromConfiguration
Dtachkp,fieldFixedLengths = 18,13,13,35,15,3,8,2,21
Dtachkp,fieldNames = F1,F2,F3,F4,F5,F6,F7,F8,F9
Dtachkp,processFieldNames = fromConfiguration
Thanks,
DaveHi,
you can use the module from which u can convert your structure to
H011000390 Customer Americas 20080605164317 000000000000000800000008000000000016000000
D12345678 100500 100500 Supplier 1 0000000000030000002008040400
D12345678 100501 100501 Supplier 2 0000000000052000002008042100
Please note the extra H,D in the struture added by the module.
You can then use them as your key fieldValues.. The module should be deployed in Visual Admin and then can be used in the Module tab of your adapter CC
While writing the content conversion after that please dont forget about the added new characters
Please note also that i can find that the word supplier kept repeating in all the Dtachkp records
Please use that
Also if you feel that the field is of 13 characters and that would cause a problem dont worry... create a dummy field eg split tht 13 to two fields and use the common one as key field Value and identifier... as i see in ure case its like 500 Supplier , 502 Supplier . u can split the first 4 char and the remaing 9 char are key field value.
try this out
Rgds
Aditya -
Hi All,
I' am trying to write data into application server using Transfer statement.
Sometimes data would not be present in last fields, so the file length is varying.
How to have fixed file length?
regards,
AravindIf you are downloading the file to application server with TRANSFER statement and LENGTH option, your spaces will be there at the end of the record. Just do not try to look at the file from within SAP environment (like using AL11). Try to get the file to your desktop and you can see that it will have those spaces.
If you using GUI_DOWNLOAD, then set the parameter TRUNC_TRAILING_BLANKS_EOL to SPACE (it is defaulted to 'X'). -
Sql loader - Data loading issue with no fixed record length
Hi All,
I am trying to load the following data through sql loader. However the records # 1, 3 & 4 are only loading succesfully into the table and rest of the records showing as BAD. What is missing in my syntax?
.ctl file:
LOAD DATA
INFILE 'C:\data.txt'
BADFILE 'c:\data.BAD'
DISCARDFILE 'c:\data.DSC' DISCARDMAX 50000
INTO TABLE icap_gcims
TRAILING NULLCOLS
CUST_NBR_MAIN POSITION(1:9) CHAR NULLIF (CUST_NBR_MAIN=BLANKS),
CONTACT_TYPE POSITION(10:11) CHAR NULLIF (CONTACT_TYPE=BLANKS),
INQUIRY_TYPE POSITION(12:13) CHAR NULLIF (INQUIRY_TYPE=BLANKS),
INQUIRY_MODEL POSITION(14:20) CHAR NULLIF (INQUIRY_MODEL=BLANKS),
INQUIRY_COMMENTS POSITION(21:60) CHAR NULLIF (INQUIRY_COMMENTS=BLANKS),
OTHER_COLOUR POSITION(61:75) CHAR NULLIF (OTHER_COLOUR=BLANKS),
OTHER_MAKE POSITION(76:89) CHAR NULLIF (OTHER_MAKE=BLANKS),
OTHER_MODEL_DESCRIPTION POSITION(90:109) CHAR NULLIF (OTHER_MODEL_DESCRIPTION=BLANKS),
OTHER_MODEL_YEAR POSITION(110:111) CHAR NULLIF (OTHER_MODEL_YEAR=BLANKS)
data.txt file:
000000831KHAN
000000900UHFA WANTS NEW WARRANTY ID 000001017OHAL
000001110KHAP
000001812NHDE231291COST OF SERVICE INSPECTIONS TOO HIGH MAXIMA 92 MK
000002015TPFA910115CUST UPSET WITH AIRPORT DLR. $200 FOR PLUGS,OIL,FILTER CHANGE. FW
Thanks,Hi,
Better if you have given the table structure, I check your script it was fine
11:39:01 pavan_Real>create table test1(
11:39:02 2 CUST_NBR_MAIN varchar2(50),
11:39:02 3 CONTACT_TYPE varchar2(50),
11:39:02 4 INQUIRY_TYPE varchar2(50),
11:39:02 5 INQUIRY_MODEL varchar2(50),
11:39:02 6 INQUIRY_COMMENTS varchar2(50),
11:39:02 7 OTHER_COLOUR varchar2(50),
11:39:02 8 OTHER_MAKE varchar2(50),
11:39:02 9 OTHER_MODEL_DESCRIPTION varchar2(50),
11:39:02 10 OTHER_MODEL_YEAR varchar2(50)
11:39:02 11 );
Table created.
11:39:13 pavan_Real>select * from test1;
no rows selected
C:\Documents and Settings\ivy3905>sqlldr ara/ara@pavan_real
control = C:\control.ctl
SQL*Loader: Release 9.2.0.1.0 - Production on Sat Sep 12 11:41:27 2009
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Commit point reached - logical record count 5
11:42:20 pavan_Real>select count(*) from test1;
COUNT(*)
5 control.ctl
LOAD DATA
INFILE 'C:\data.txt'
BADFILE 'c:\data.BAD'
DISCARDFILE 'c:\data.DSC' DISCARDMAX 50000
INTO TABLE test1
TRAILING NULLCOLS
CUST_NBR_MAIN POSITION(1:9) CHAR NULLIF (CUST_NBR_MAIN=BLANKS),
CONTACT_TYPE POSITION(10:11) CHAR NULLIF (CONTACT_TYPE=BLANKS),
INQUIRY_TYPE POSITION(12:13) CHAR NULLIF (INQUIRY_TYPE=BLANKS),
INQUIRY_MODEL POSITION(14:20) CHAR NULLIF (INQUIRY_MODEL=BLANKS),
INQUIRY_COMMENTS POSITION(21:60) CHAR NULLIF (INQUIRY_COMMENTS=BLANKS),
OTHER_COLOUR POSITION(61:75) CHAR NULLIF (OTHER_COLOUR=BLANKS),
OTHER_MAKE POSITION(76:89) CHAR NULLIF (OTHER_MAKE=BLANKS),
OTHER_MODEL_DESCRIPTION POSITION(90:109) CHAR NULLIF (OTHER_MODEL_DESCRIPTION=BLANKS),
OTHER_MODEL_YEAR POSITION(110:111) CHAR NULLIF (OTHER_MODEL_YEAR=BLANKS)
data.txt
000000831KHAN
000000900UHFA WANTS NEW WARRANTY ID 000001017OHAL
000001110KHAP
000001812NHDE231291COST OF SERVICE INSPECTIONS TOO HIGH MAXIMA 92 MK
000002015TPFA910115CUST UPSET WITH AIRPORT DLR. $200 FOR PLUGS,OIL,FILTER CHANGE. FW
CUST_NBR_MAIN CONTACT_TYPE INQUIRY_TYPE INQUIRY_MODEL INQUIRY_COMMENTS OTHER_COLOUR OTHER_MAKE OTHER_MODEL_DESCRIPTION OTHER_MODEL_YEAR
000000831 KH AN NULL NULL NULL NULL NULL NULL
000000900 UH FA WANTS NEW WARRANTY ID 000001017OHAL NULL NULL NULL NULL
000001110 KH AP NULL NULL NULL NULL NULL NULL
000001812 NH DE 231291C OST OF SERVICE INSPECTIONS TOO HIGH MAXI MA 92 MK NULL NULL NULL
000002015 TP FA 910115C UST UPSET WITH AIRPORT DLR. $200 FOR PLU GS,OIL,FILTER C HANGE. FW NULL NULL- Pavan Kumar N
Edited by: Pavan Kumar on Sep 12, 2009 11:46 AM -
How to convert Mail attachment file Tab Delimited file to XML.
Hi PI Experts
I have XI scenario: MAIL XI SAP (ABAP Proxy), the process is
1. XI will receive tab delimited file as attachment in mail.
2. XI will convert the tab delimited file into XML, then map to the target structure.
3. Target will be posted into ECC through ABAP Proxy.
Can anyone help me how can I convert the attachment file (i.e. Tab delimited file) to XML while configuring the sender side.
Thanks in AdvanceI just grabed what I answered from another thread. It should work.
Processing sequence as follows:
1. localejbs/AF_Modules/PayloadSwapBean Local Enterprise Bean swap1
2. localejbs/AF_Modules/MessageTransformBean Local Enterprise Bean tran1
3. sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean Local Enterprise Bean mail
Module Configuration as follows: Fill the XXXX part with your info.
swap1 swap.keyName payload-name
swap1 swap.keyValue MailAttachment-1
tran1 Transform.Class com.sap.aii.messaging.adapter.Conversion
tran1 Transform.ContentType ext/xml;charset=utf-8
tran1 xml.conversionType SimplePlain2XML
tran1 xml.documentName XXXXXXX_Mail
tran1 xml.documentNamespace http://XXXXX.com.au/XXXX
tran1 xml.fieldSeparator \t
tran1 xml.processFieldNames fromConfiguration
tran1 xml.structureTitle rows
Once you set up the above configuration, you will get one record at a time.
Create a souce message interface like the followings:
XXXXXXXXX_Mail
rows
record
Target message interface:
XXXXXXXXX
rows
field 1
field 2
field 3
Write a UDF function to remove the TAB space
public removeTABSpace(String record,Container container){
//write your code here
StringTokenizer st = new StringTokenizer(record,"\t",false);
String t="";
while (st.hasMoreElements()) t += st.nextElement();
return t;
Write another UDF to get the field 1 for example:
public String getField1(String input,Container container){
int counter=0;
int beginIndex=0;
int endIndex=0;
int i;
for (i=0;i<input.length();i++){
if (input.charAt(i)==34){
counter=counter+1;
if (counter==1){
beginIndex=i+1;
counter=0;
break;
for (i=0;i<input.length();i++){
if (input.charAt(i)==34){
counter=counter+1;
if (counter==2){
endIndex=i;
counter=0;
break;
input=input.substring(beginIndex,endIndex);
return input;
Get the mapping like the followings:
record - removeTABSpace - getField1 - field 1
If you need to get field 2, you will need to write another UDF similar to the above one to handle it. -
Problems with Adapter module converting Excel file to XML
Hi All,
I have created an adapter moduel to convert the input excel file to XML and have deployed it. While testing we found that there is an extra empty record with empty elements added additionally. Can anyone help on this?
Below is the convert function used for it.
public byte[] convert(byte src[],String msgType,String nameSpace) throws Exception
String xmldata = "";
try
ByteArrayInputStream byteArr= new ByteArrayInputStream(src);
Workbook wb = Workbook.getWorkbook(byteArr);
Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"AO: Conversion Started.");
xmldata ="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n"+ "<ns0:"+msgType+" "+"xmlns:ns0=\""+nameSpace+"\">";
Cell[] cells ;
Cell[] cellNames ;
cellNames = wb.getSheet(0).getRow(4);
for(int j=5;j<wb.getSheet(0).getRows();j++)
xmldata = xmldata+"<Record>";
cells = wb.getSheet(0).getRow(j);
for(int i=1;i<wb.getSheet(0).getColumns();i++)
xmldata = xmldata+"<"+cellNames<i>.getContents().replaceAll(" ","")+">"+cells<i>.getContents()+"</"+cellNames<i>.getContents().replaceAll(" ","")+">";
xmldata = xmldata+"</Record>";
xmldata = xmldata + "</ns0:"+msgType+">";
wb.close();
catch (Exception e)
Audit.addAuditLogEntry(amk, AuditLogStatus.SUCCESS,"AO: Exception in Convert Method.");
return xmldata.getBytes();
Regards,
Malini
Edited by: malini balasubramaniam on Mar 5, 2010 7:28 AMHi,
xmldata = xmldata+"<Record>";
cells = wb.getSheet(0).getRow(j);
for(int i=1;i<wb.getSheet(0).getColumns();i++)
xmldata = xmldata"<"cellNames<i>.getContents().replaceAll(" ","")">"cells<i>.getContents()"</" ","")">";
xmldata = xmldata+"</Record>";
Can u please change this part of code as
Hi,
cells = wb.getSheet(0).getRow(j);
if(cells.size()>0)
xmldata = xmldata+"<Record>";
for(int i=1;i<wb.getSheet(0).getColumns();i++)
xmldata = xmldata"<"cellNames<i>.getContents().replaceAll(" ","")">"cells<i>.getContents()"</" ","")">";
xmldata = xmldata+"</Record>";
Check first if the row is empty...
im nt sure it is cells.size() or cells.length.. please try both
Thanks & Regards
Babu -
How can convert HTML file into xml file?
Hi,
I am receving one HTML file as an input and i want to convert that receiving(html file) into .xml file.Is there any converter (tools)to do this.Pls if any give me the details with regard.
Regards,
mahesh.Use the HTMLEditorKit to parse the html file.
this kit is having the callback methods which
are called wenever the tag appears in the HTML
stream. -
XSLT Mapping : XML to Fixed Length File
Hi,
I have to code a XSLT mapping which converts the XML into a Fixed Length File Format. I am getting the output but it has some garbage values (Some extra spaces in front of first record and also extra blank lines before the first record)
I am pasting my xsl sheet :
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" indent="yes" media-type="text/plain"/>
<xsl:template match="Employees">
<xsl:for-each select="Employee">
<xsl:value-of select="Name"/>
<xsl:value-of select="ID"/>
<xsl:value-of select="ADD"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
My input XML file is as follows:
<?xml version="1.0"?>
<p1:Test02 xmlns:p1="http://www.infosys.com/xi/training/hyd/66289">
<Employees>
<Employee>
<Name>Anurag</Name>
<ID>1121</ID>
<ADD>Hyderabad</ADD>
</Employee>
<Employee>
<Name>Divya</Name>
<ID>1122</ID>
<ADD>Hyderabad</ADD>
</Employee>
<Employee>
<Name>Rasmi</Name>
<ID>1123</ID>
<ADD>Bangalore</ADD>
</Employee>
</Employees>
</p1:Test02>
And the output i am receiving is as follows:
Anurag1121Hyderabad
Divya1122Hyderabad
Rasmi1123Bangalore
Please do help.....hi,
>>>>
<xsl:output method="text" indent="yes" media-type="text/plain"/>
you allow the spaces by using indent="yes"
try with indent="no"
Regards,
michal
<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a> -
Reading fixed length file with different record types
Hi,
I need to read a fixed-length file with different record types, but the record identifier is in 31st position and not in 1st position.
But if I give 31 as position in File adpater wizard, BPEL takes whole 1-31 as identifier.
How we need to read such files.
Thanks
Ravdeephi ,
u cannot use the default wzard for this
use some thing like this nxsd:lookAhead="30" nxsd:lookFor="S"have a look at the below link it has some examples
http://download.oracle.com/docs/cd/B31017_01/integrate.1013/b28994/nfb.htm -
Convert the Database records to a standard XML file format?
Hai,
i want to convert the Database records to a standard XML file
format which includes the schema name, table name, field name
and field value. i am using Oracle 8.1.7. Is there any option
please help me
Thanks in advance.You could put the files somewhere and I can export them as QuickTime. Or you could find anyone you know who has Director. Or do the 30 day trial download
Another approach would be to play the DCR in a browser window, and do a screen recording. But that’s unlikely to give the perfect frame rate that you would get by exporting from Director. -
Hi
i just want to read flat file and convert it into xml but there are some problem ,it throws a ArrayIndexOutOfBoundException.Here is code.
import java.io.*;
import java.util.*;
class FlatXMLBudget {
public static void convert(List data, OutputStream out)
throws IOException {
Writer wout = new OutputStreamWriter(out, "UTF8");
wout.write("<?xml version=\"1.0\"?>\r\n");
wout.write("<Budget>\r\n");
Iterator records = data.iterator();
while (records.hasNext()) {
wout.write(" <LineItem>\r\n");
Map record = (Map) records.next();
Set fields = record.entrySet();
Iterator entries = fields.iterator();
while (entries.hasNext()) {
Map.Entry entry = (Map.Entry) entries.next();
String name = (String) entry.getKey();
String value = (String) entry.getValue();
// some of the values contain ampersands and less than
// signs that must be escaped
//value = escapeText(value);
wout.write(" <" + name + ">");
wout.write(value);
wout.write("</" + name + ">\r\n");
wout.write(" </LineItem>\r\n");
wout.write("</Budget>\r\n");
wout.flush();
public static String escapeText(String s) {
if (s.indexOf('&') != -1 || s.indexOf('<') != -1
|| s.indexOf('>') != -1) {
StringBuffer result = new StringBuffer(s.length() + 4);
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '&') result.append("&");
else if (c == '<') result.append("<");
else if (c == '>') result.append(">");
else result.append(c);
return result.toString();
else {
return s;
public static void main(String[] args) {
try {
/*if(args.length<1)
System.out.println("Usage: FlatXMLBudget infile outfile");
return;
InputStream in = new FileInputStream("d:\\file.txt");
OutputStream out;
int a=in.available();
System.out.println("dd:"+a);
/*if (args.length < 2) {
out = System.out;
else {*/
List results = BudgetData.parse(in);
int aa=results.size();
System.out.println("dd:"+aa);
out = new FileOutputStream("d:\\flattoxml.xml");
convert(results, out);
catch (IOException e) {
System.err.println(e);
import java.io.*;
import java.util.*;
class BudgetData
public static List parse(InputStream src) throws IOException
// The document as published by the OMB is encoded in Latin-1
InputStreamReader isr = new InputStreamReader(src, "8859_1");
BufferedReader in = new BufferedReader(isr);
List records = new ArrayList();
String lineItem;
while ((lineItem = in.readLine()) != null)
records.add(splitLine(lineItem));
return records;
// the field names in order
public final static String[] keys = {
"AgencyCode",
"AgencyName",
"BureauCode",
"BureauName",
"AccountCode",
"AccountName",
"TreasuryAgencyCode",
"SubfunctionCode",
"SubfunctionTitle",
"BEACategory",
"On-Off-BudgetIndicator",
"FY1976", "TransitionQuarter", "FY1977", "FY1978", "FY1979",
"FY1980", "FY1981", "FY1982", "FY1983", "FY1984", "FY1985",
"FY1986", "FY1987", "FY1988", "FY1989", "FY1990", "FY1991",
"FY1992", "FY1993", "FY1994", "FY1995", "FY1996", "FY1997",
"FY1998", "FY1999", "FY2000", "FY2001", "FY2002", "FY2003",
"FY2004", "FY2005", "FY2006"
private static Map splitLine(String record)
record = record.trim();
int index = 1;
Map result = new HashMap();
for (int i = 1; i < keys.length; i++)
//find the next comma
StringBuffer sb = new StringBuffer();
char c;
boolean inString = false;
while (true)
c = record.charAt(index);
if (!inString && c == '"') inString = true;
else if (inString && c == '"') inString = false;
else if (!inString && c == ',') break;
else sb.append(c);
index++;
if (index == record.length()) break;
String s = sb.toString().trim();
result.put(keys, s);
index++;
return result;
[output/error]
java.lang.StringIndexOutOfBoundsException: String index out of range: 71
at java.lang.String.charAt(String.java:444)
at BudgetData.splitLine(BudgetData.java:55)
at BudgetData.parse(BudgetData.java:16)
at FlatXMLBudget.main(FlatXMLBudget.java:79)
Exception in thread "main"
[output/error]
Can any one help me about this problem.Off-by-one error.
In a String of length 70, for example, the characters are numbered from 0 to 69 in Java. Your program is written as if they were numbered from 1 to 70. So when you try to get #70, the exception occurs.
But if you want to use commas as a delimiter to break a string into substrings, it's much easier just to use the split() method of String than to write all that code you have there.
Maybe you are looking for
-
Can I put more than one user under one Apple ID account. I want to let other family members use imessage on their own Apple device. Or is there another way to get this end result?
-
Why does Logic 9 not work with Snow Leopard?
I have the basic system and it fails to load everytime. Had to reinstall Leopard and lost all my prefs... very much a pain. I don't understand why Apple makes updated operating systems and doesn't ensure that their own products are compatible. App
-
Calling stored procedure using jdbc
Hi all, I'm new to jdbc calling pl/sql and I have a very simple question. I'd like to execute this before I read data from the table: BEGIN packageA.functionA(1234567890123456); END; My jdbc code: try { DriverManager.registerDriver (new oracle.jdbc.d
-
When I click a bookmark it opens in the bookmark side bar, not in the main window.
I want a selected bookmark to open in the main browser window when I click it (as it has always done before)
-
Firmware re-loaded.. still not working! should i just switch to ipod or wh
this thing is gettign thrown out the window soon. after having numerous and frustrating problems.. my zen will take charge (about bloody time!) i can get to recovery mode and i managed to re load the firmware.. ? but ? organiser still doesnt recognis