How to read files with codepage UTF16LE with "Sender File Adapter"
Hi everybody,
I am using a XI-Filesender-Adapter to get a (UTF-16LE encoded) file und process it in XI-Mapping.
This is my File-Content:
Cost Centre,Cost Code,Page Count (B&W),Page Count (Colour),Job Count
Unknown,Lexmark,"37,480",334,"11,968"
Unknown,Unknown,312,0,177
110000,Lexmark,128,228,43
The HEX-representation of this content is:
FF FE 43 00 6F 00 73 00 74 00 20 00 43 00 65 00
(The starting 2 Bytes FF FE represent UTF16-LE )
And this is the payload I get for mapping:
<?xml version="1.0" encoding="utf-8" ?>
<ns:MT_POM_KOSTEN xmlns:ns="http://aua.com/pom">
<POM_REC>
<COSTCENTER>uFEFFCost Centre</COSTCENTER>
<COSTCODE>Cost Code</COSTCODE>
<PAGECOUNT_BW>Page Count (B&W)</PAGECOUNT_BW>
<PAGECOUNT_COL>Page Count (Colour)</PAGECOUNT_COL>
<JOBCOUNT>Job Count</JOBCOUNT>
</POM_REC>
<POM_REC>
<COSTCENTER>Unknown</COSTCENTER>
<COSTCODE>Lexmark</COSTCODE>
<PAGECOUNT_BW>37,480</PAGECOUNT_BW>
<PAGECOUNT_COL>334</PAGECOUNT_COL>
<JOBCOUNT>11,968</JOBCOUNT>
</POM_REC>
<POM_REC>
<COSTCENTER>Unknown</COSTCENTER>
<COSTCODE>Unknown</COSTCODE>
<PAGECOUNT_BW>312</PAGECOUNT_BW>
<PAGECOUNT_COL>0</PAGECOUNT_COL>
<JOBCOUNT>177</JOBCOUNT>
</POM_REC>
<POM_REC>
<COSTCENTER>110000</COSTCENTER>
<COSTCODE>Lexmark</COSTCODE>
<PAGECOUNT_BW>128</PAGECOUNT_BW>
<PAGECOUNT_COL>228</PAGECOUNT_COL>
<JOBCOUNT>43</JOBCOUNT>
<POM_REC>
I can see the correct strings (for example Cost Centre) in payload, but the string-comparison in the user defines function cannot recognize the equality of the strings:
for (int i =0; i < a.length; i++) {
if (
(a<i>.equals("Cost Centre")) )
result.addSuppress();
else
result.addValue("");
Actually I am using UTF-8 as codepage in Fileadapter (and Text as type)
When I try to use UTF16 (or UTF-16LE) as Codepage, I am getting unreadable characters.
I also tried binary, UTF16-BE,...
The only way is to covert the file to ANSI before I use it with XI. Then my function does work correctly.
Does anybody have an idea, how I can read a UTF16-LE File and process it correctly in XI?
I am using XI 7.00 0023 and JSDK 1.4.2-34
Thanks a lot
Armin
Hello Armin,
I have gone through some SAP notes and blogs to find solution to your problem, here is what I found
1. SAP NOTE 821267
q) How do I correctly configure the File Encoding used by the File
Adapter?
Flat Files with File Content Conversion
For a File Sender channel, configure the encoding of the source
file. The file will be interpreted according to the configured
encoding and converted to XML with an UTF-8 encoding.
For a File Receiver channel, configure the encoding to match
the encoding you would like to be written to the target flat
file.
- Flat Files without File Content Conversion
Whether to configure an encoding in this case depends on if you
want to pass through the file "as is", e.g. within a File
Sender to File Receiver scenario, or if you want to convert the
file's encoding on its way through the Integration Server. For
"as is" processing, configure both the sender and the receiver
using the File Type setting "Binary".
To apply an encoding conversion, configure the respective
source and target encoding in both the sender and receiver
channel.
Important: Configuring an encoding in the receiver channel
will only lead to the expected results if the payload sent to
the receiver channel is in UTF-8 format (e.g., by having
specified an encoding conversion in the Sender channel).
So as per this note if you configure the encoding scheme of sender communication channel to UTF-16LE, adapter should be able to convert it to UTF-8 by default. But you have posted that this encoding scheme is leading to unreadable charcters
2) SAP note 880173
This speaks of use of module XMLAnonymizerBean which can be applied to XML payload to change its encoding.
3) How to guide on encoding : http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/502991a2-45d9-2910-d99f-8aba5d79fb42?QuickLink=index&overridelayout=true
4) SAP note:960663
http://help.sap.com/saphelp_nw04/helpdata/en/45/da2deb47812e98e10000000a155369/content.htm
TextCodePageConversion Bean details which might solve your problem.
5) Finally if nothing above works you need a java mapping code to convert to target XML structure without any File content conversion. The mapping will convert the received file to proper target XML in "UTF-8" encoding. Please let us know if you need help on the code with this final option.
Regards
Anupam
Similar Messages
-
How to read and update the value of property file
Hi,
I am not able read the values from property file.
Please tell me how to read and update the values from property file using Properties class
This is my property file : - Config.properties its located in D:\newfolder
Values
SMTP = localhost
Now i need to change the value of the SMTP
New value :
SMTP =10.60.1.9
Pls Help me
Thanks
Merlin Rosina,Post a small (<1 page) example program that forum members can copy and run that demonstrates your problem.
-
How to read data from a zipped MS Access file?
How to read data from a zipped MS Access file?
RPJ,
You do not need to use the Close Zip File.vi when you unzip a folder. This VI is used when you are creating a zip folder.
As for examples, I found a couple of ActiveX based MS Access examples. These programs look to be pretty basic. For more in depth example I would search Microsoft Developers Network
http://zone.ni.com/devzone/cda/epd/p/id/2188
http://zone.ni.com/devzone/cda/epd/p/id/1694
Regards,
Jon S.
National Instruments
LabVIEW R&D -
How to read and write a data from extrenal file
Hi..
How to read and write a data from extrenal file using Pl/sql?
Is it possible from Dyanamic Sql or any other way?
Reagards
Rajuutl_file
Re: How to Create text(dat) file.
Message was edited by:
jeneesh -
How to pick files from multiple directories via Sender File Adapter?
Hi guys,
I have a scenario File to IDOC. The Sender File Adapter has to take all files: .xml from Source directory E://Current/.
Actually directories are like
E:/Plant1/Current/
E:/Plant1/History/
E:/Plant2/Current/
E:/Plant2/History/.
Can I have one Sender File Adapter to pick all *.xml files
from
E:/Plant1/Current/ and
E:/Plant2/Current/ and how can I write it in Source Directory of Communication Channel?
Or do I have to have a Sender File Adapter for each Plant?
Any suggestion please?
Kind regards,
Danijela ZivanovicHey
You might wanna have a look at "Additional selection for source file" parameter in sender file adapter.
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/xi/singleSenderFileCC4MultipleDirectories
XI/PI: how to exclude files in a sender File adapter?
Even though this method works but there are some constraints,please check help.sap.com for constraints.
Thanx
Aamir -
How to read columns of a Microsoft Excel .csv file with LabVIEW?
This should be simple. Any ideas on how to read an Excel file with csv extension using LabVIEW?
Thanks!Use the Read From SpeadSheet File.VI which you can find on the FILE I/O pallette.
"Read From Spreadsheet File
Reads a specified number of lines
or rows from a numeric text file beginning at a specified character offset and
converts the data to a 2D, single-precision array of numbers. You optionally can transpose the
array. The VI opens the file before reading from it and closes it afterwards.
You can use this VI to read a spreadsheet file saved in text format. This VI
calls the Spreadsheet String
to Array function to convert the data."
The CSV file is essentially a text file which uses commas as delimiters in the files structure. -
How to read from an internal table with multiple key fields.
Hi All!!
I want to read from an internal table having keys as k1,k2,k3.
How can I use read statement to read an entry having this as the key fields.
Thanks in adavance..
Prabhas Jhahi there
use:
sort itab by K1 K2 K3.
read table itab into wa with key K1 = value 1
K2 = value2
K3 = value 3
BINARY SEARCH.
where:
itab is ur internal table
wa is the work area with the same line type as the itab
cheers
shivika -
How to read new SWF bytecode compiled with ASC2
I need to get the build date from the bytecode, but SWFs generated by ASC2 produce bytes in a different order than the ASC1 does.
Anybody know how to read it?
cheersNot sure if this is what you mean, but one of them uses zlib and the other uses lzma compression and the corresponding first letter of the file is f rather than z (I think... would need to double check). The lzma compression makes a big difference - roughly a third smaller for some of my SWF.
-
How to read from a certain location is a file?
hi! i am new to programing and i have a problems abt reading from a file. i have write the following to a file using FmtFile :
10 (a numbers)
name,phone,product (some strings)
9 (a numbers)
when i user ScanFile to read the second number(9 in the above example), i got a wrong value. the command i use is:
ScanFile (filehandle, "%d", &number1);
ScanFile (filehandle, "%s[t44]%s[t44]%s",name, phone product);
ScanFile (filehandle, "%d", &number2);
number1 and number 2 are integers and name, phone and product are char arrays.
can anyone tell me where have i gone wrong? or maybe someone can tell me how can i read the 2nd number without reading the 1st number
and the strings.Let's look at your file: if I correctly interpret your question, one row in it should like like this:
10,name,phone,product,9
In this case you could use the following formatting string to read all data from the string:
"%d[x]%s[xt44]%s[xt44]%s[xt44]%d"
[x] means to discard terminator, in order to read from strings, for example, "name" and not "name,". It's important in this case to put ALL field separators.
Maybe your problem is that in the file you don't have separators between strings and numbers: in this case the last "%s" should read the '9' inside the last string and the subsequent "%d" matches with incorrect area in the file (end-of-line or next row).
Hope this help
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos? -
How to read a BLOB (base64 - stream) from XML-file in ORACLE10
ORACLE 10g
PL/SQL function
MY XML-file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<slo xmlns="http://www.example.org/detection">
<LekKey>1999_036371_509627</LekKey>
<HuiNum>46</HuiNum>
<Res></Res>
<InfLig>TEST STRUI AFGESTORVEN - PLAANSTRAAT 46</InfLig>
<XWGS>3.637028</XWGS>
<YWGS>50.962667</YWGS>
<Pei>EANDIS</Pei>
<DatPei>1999-11-30T10:17:36.000+01:00</DatPei>
<Kan> </Kan>
<Doc>UEsDBBQABgAIAAAAIQB5gHbnswEAAHcGAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAA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dlYlNldHRpbmdzLnhtbFBLAQItABQABgAIAAAA
IQDQwaCR/gEAAGgEAAAQAAAAAAAAAAAAAAAAAH8/CQBkb2NQcm9wcy9hcHAueG1sUEsFBgAAAAASABIA
pQQAALNCCQAAAA==</Doc>
</slo>
I have to write an PL/SQL function where I can read all the data in the XML-file (see attach).
In this XML there is a BLOB stored (base64 - stream -> that contains always a MSWORD document).
1) how can I extract this BLOB + the other data in the XML and save this data in a ORACLE table?
2) how can I decode this BLOB and save this MSWORD-document to a fileserver?First extract your data as CLOB (as it's character based)...
SQL> ed
Wrote file afiedt.buf
1 with t as (select xmltype('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2 <slo xmlns="http://www.example.org/detection">
3 <LekKey>1999_036371_509627</LekKey>
4 <HuiNum>46</HuiNum>
5 <Res></Res>
6 <InfLig>TEST STRUI AFGESTORVEN - PLAANSTRAAT 46</InfLig>
7 <XWGS>3.637028</XWGS>
8 <YWGS>50.962667</YWGS>
9 <Pei>EANDIS</Pei>
10 <DatPei>1999-11-30T10:17:36.000+01:00</DatPei>
11 <Kan> </Kan>
12 <Doc>UEsDBBQABgAIAAAAIQB5gHbnswEAAHcGAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AA
AAAAAAAAADA4CQB3b3JkL2ZvbnRUYWJsZS54bWxQSwECLQAUAAYACAAAACEAp/3kQ44BAADeAgAAEQAAAAAAAAAAAAAAAACYOgkAZG9jUHJvcHMvY29yZS54bWxQSwECLQAUAAYACAAAACEAqchcqowAAADaAAAAEwAAAAAAAAAAAAAAAABdPQkAY3VzdG9tWG1sL2l0ZW0xLnhtbFBLAQItABQABgAIAAAAIQBgX/2ICwEAALoBAAAUAAAAAAAA
AAAAAAAAAEI+CQB3b3JkL3dlYlNldHRpbmdzLnhtbFBLAQItABQABgAIAAAAIQDQwaCR/gEAAGgEAAAQAAAAAAAAAAAAAAAAAH8/CQBkb2NQcm9wcy9hcHAueG1sUEsFBgAAAAASABIApQQAALNCCQAAAA==</Doc>
13 </slo>') as xml from dual)
14 --
15 -- end of test data
16 --
17 select x.*
18 from t
19 ,xmltable(xmlnamespaces(default 'http://www.example.org/detection'),
20 '/slo'
21 passing t.xml
22 columns lekkey varchar(30) path './LekKey'
23 ,doc clob path './Doc'
24* ) x
SQL> /
LEKKEY DOC
1999_036371_509627 UEsDBBQABgAIAAAAIQB5gHbnswEAAHcGAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAADA4CQB3b3JkL2ZvbnRUYWJsZS54bWxQSwECLQAUAAYACAAAACEAp/3kQ44BAADeAgAA
EQAAAAAAAAAAAAAAAACYOgkAZG9jUHJvcHMvY29yZS54bWxQSwECLQAUAAYACAAAACEAqchcqowAAADa
AAAAEwAAAAAAAAAAAAAAAABdPQkAY3VzdG9tWG1sL2l0ZW0xLnhtbFBLAQItABQABgAIAAAAIQBgX/2I
CwEAALoBAAAUAAAAAAAAAAAAAAAAAEI+CQB3b3JkL3dlYlNldHRpbmdzLnhtbFBLAQItABQABgAIAAAA
IQDQwaCR/gEAAGgEAAAQAAAAAAAAAAAAAAAAAH8/CQBkb2NQcm9wcy9hcHAueG1sUEsFBgAAAAASABIA
pQQAALNCCQAAAA==
SQL>Then, you can convert the CLOB to a BLOB by doing your base64 decoding. -
Mac Mini Sever - Public Share - how enable read and write permissions for new remote files
Hi,
this Sunday a friend ask me to help hum with a problem on is Man Mini Server. He has a small office and uses the mini server to share a public folder to all his employees.
Everyone that creates a file, saves it to the public folder at the mini mac.
That problem is that, who creates the file owns it and remains with read-only permissions to everyone else. The owner has to change the file permission in order to the rest of the employees can work on it.
I do not know mac arquitecture, I only work with windows and linux, but i suspect the principles are the same.
We try to create another folder , and share it, but it happens the same. Have you any ideas on what is wrong?
I suspect it has anything to do with de file Sharing at the mini mac, but it has read and write permissions for everyone.
Thanks for your help.signed applet. You aren't going to find any easy way to distribute that policy file to users, and that policy file, if you asked me to put it on my PC, I'd tell you to take a flying leap. That would open any applet to access.
-
How to read a specific line of a .dat file?
can we read a specific line of a .dat file, if so, how?
i have this .dat files for each customer, which contain their name on the first line, their id on the second line
and a list of items and an item id between each item.
John Doe
455689
milk
1
orange
9
Here is what I am trying to do, please correct me
//list out .dat file in dir
File customer_dir = new File ("Customer")
if (customer_dir.isDirectory())
String[] listofdat=dir.list();
for (int i=0;i<listofdat.length();i++)
Scanner dat_read = new Scanner (new File listfodat);
dat_read.nextLine();
if (dat_read.nextLine().equals("455689")) <--is this okay?bibiancheng wrote:
would you please explain to me what
String[] tokens = line.trim().split("\\s*,\\s*")"\\s*,\\s*" is a regex where \\s means whitespace and the * means "any number of".
so \\s* means that it will grab all the whitespace if there is any.
trim() removes white space from the beginning and end of the string.
dont put a comma in the name.
spaces allowed: "jane doe, 12-14-09, 428438, 6, 388473, 7, 187374, 3"
it was just a recommendation. breaking it into separate lines would be fine. -
How to read from and write into the same file from multiple threads?
I need to read from and write into a same file multiple threads.
How can we do that without any data contamination.
Can u please provide coding for this type of task.
Thanks in advance.Assuming you are using RandomAccessFile, you can use the locking functionality in the Java NIO library to lock sections of a file that you are reading/writing from each thread (or process).
If you can't use NIO, and all your threads are in the same application, you can create your own in-process locking mechanism that each thread uses prior to accessing the file. That would take some development, and the OS already has the capability, so using NIO is the best way to go if you can use JDK 1.4 or higher.
- K
I need to read from and write into a same file
multiple threads.
How can we do that without any data contamination.
Can u please provide coding for this type of task.
Thanks in advance. -
How to read the last line in a txt file?
Dear all,
I want to read the last line in a txt file. There are thousands of lines in this file. What I want is to move the file pointer directly to the last line of the file. But I did not know how do to it. Can anybody help me out?
Thank you very much!If the file is coded as ASCII or one of the encodings that maps a single byte to a char then the following class will assist you
import java.io.*;
import java.util.*;
public class GetLinesFromEndOfFile
static public class BackwardsFileInputStream extends InputStream
public BackwardsFileInputStream(File file) throws IOException
assert (file != null) && file.exists() && file.isFile() && file.canRead();
raf = new RandomAccessFile(file, "r");
currentPositionInFile = raf.length();
currentPositionInBuffer = 0;
public int read() throws IOException
if (currentPositionInFile <= 0)
return -1;
if (--currentPositionInBuffer < 0)
currentPositionInBuffer = buffer.length;
long startOfBlock = currentPositionInFile - buffer.length;
if (startOfBlock < 0)
currentPositionInBuffer = buffer.length + (int)startOfBlock;
startOfBlock = 0;
raf.seek(startOfBlock);
raf.readFully(buffer, 0, currentPositionInBuffer);
return read();
currentPositionInFile--;
return buffer[currentPositionInBuffer];
public void close() throws IOException
raf.close();
private final byte[] buffer = new byte[4096];
private final RandomAccessFile raf;
private long currentPositionInFile;
private int currentPositionInBuffer;
public static List<String> head(File file, int numberOfLinesToRead) throws IOException
return head(file, "ISO-8859-1" , numberOfLinesToRead);
public static List<String> head(File file, String encoding, int numberOfLinesToRead) throws IOException
assert (file != null) && file.exists() && file.isFile() && file.canRead();
assert numberOfLinesToRead > 0;
assert encoding != null;
LinkedList<String> lines = new LinkedList<String>();
BufferedReader reader= new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding));
for (String line = null; (numberOfLinesToRead-- > 0) && (line = reader.readLine()) != null;)
lines.addLast(line);
reader.close();
return lines;
public static List<String> tail(File file, int numberOfLinesToRead) throws IOException
return tail(file, "ISO-8859-1" , numberOfLinesToRead);
public static List<String> tail(File file, String encoding, int numberOfLinesToRead) throws IOException
assert (file != null) && file.exists() && file.isFile() && file.canRead();
assert numberOfLinesToRead > 0;
assert (encoding != null) && encoding.matches("(?i)(iso-8859|ascii|us-ascii).*");
LinkedList<String> lines = new LinkedList<String>();
BufferedReader reader= new BufferedReader(new InputStreamReader(new BackwardsFileInputStream(file), encoding));
for (String line = null; (numberOfLinesToRead-- > 0) && (line = reader.readLine()) != null;)
// Reverse the order of the characters in the string
char[] chars = line.toCharArray();
for (int j = 0, k = chars.length - 1; j < k ; j++, k--)
char temp = chars[j];
chars[j] = chars[k];
chars[k]= temp;
lines.addFirst(new String(chars));
reader.close();
return lines;
public static void main(String[] args)
try
File file = new File("/usr/share/dict/words");
int n = 10;
System.out.println("Head of " + file);
int index = 0;
for (String line : head(file, n))
System.out.println(++index + "\t[" + line + "]");
System.out.println("Tail of " + file);
int index = 0;
for (String line : tail(file, "us-ascii", n))
System.out.println(++index + "\t[" + line + "]");
catch (Exception e)
e.printStackTrace();
}Note, the EOL characters are treated as line separators so you will probably need to read the last two lines (think about it for a bit). -
How to read sampled data info from a "*.au"file into an array?
I need to manipulate the sound file directly using DSP, the first step is to read sampled data from "*.au" file into an array. How can I do that? Thanks a lot!!
There is a file I/O tutorial in the Java Tutorial (google for Java Tutorial). You can read an .au file as bytes like any binary file.
Or if you are using the Java Sound API, google for java sound api or java audio tutorial etc etc.
Maybe you are looking for
-
Why do to dos always disappear from I-Tunes. For example, I was at work Friday and created a to do list for the up coming week today monday no to dos appear in the list?? Please advise.
-
Message Mapping: different Queues.
Hi All, I have a problem. I have a source structure where i check 2 fields. example: <root> <element> <id>Z01</id> <sub> <text>01Text</text> </sub> <element> <element> <id>Z02</id> <sub> <text>02Text</text> </sub> <element> <element> <id>Z03</id>
-
DDX for disassembling packaged files
Hello, I created a very basic pdf portfolio using assembler service. My ddx for the same - <DDX xmlns="http://ns.adobe.com/DDX/1.0/"> <PDF result="Assembled Form"> <PDF source="cover" baseDocument="true"/> <PackageFiles> <PDF source="
-
Bapi to Asign standing instructions to BP (Authorizations).
Hi all. I'm using BAPI_BUPA_ROLE_ADD_2 to asing role TR0150 to the Business Partner. I would like to determine the Standing Instructions to this BP. Particularly the SI: Authorizations. I can't find this BAPI. Is there a BAPI to assign this informati
-
Best way to install Master Collection CS5
Ok, some of you may think this is a dumb question but after the absolute torture I went through with loading up my CS3 MC over the years on previous pcs I'm gonna ask it anyway. I have a Vista 64 workstation / 10K Raptor boot disk with plenty of spac