Problem in reading a resource file form JAR

Problem in finding a resource file from the jar.....
I have my code in the following directory structure
rootDir -
     libDir -
          XMLEntities.res
     modelDir -
          File1
          File2
          File3
Step1 - I create a jar file with root as modelDir and with all its files.
Step2 - I add XMLEntities.res also to the root of the jar
If I run my application using
java -classpath ;C:\aip_build\build_dm\rmi_server_files\dm.jar; model.data_model.ActivateDataManager
My application which uses Xalan.jar (lyong under ext directory in jdk) does not find XMLEntiries.res.
If I use my application as under without creating jar my application does find XMLEntites.res
Can anyone tell me why the application can not find the XMLEntities.res inside jar?

Sorry I missed one line............
Problem in finding a resource file from the jar.....
I have my code in the following directory structure
rootDir -
----libDir -
--------XMLEntities.res
----modelDir -
--------File1
--------File2
--------File3
Step1 - I create a jar file with root as modelDir and
with all its files.
Step2 - I add XMLEntities.res also to the root of the
jar
If I run my application using
java -classpath
;C:\aip_build\build_dm\rmi_server_files\dm.jar;
model.data_model.ActivateDataManager
My application which uses Xalan.jar (lyong under ext
directory in jdk) does not find XMLEntiries.res.
If I use my application as under without creating jar
my application does find XMLEntites.res
java -classpath
;C:\aip_build\build_dm\rmi_server_files\;C:\aip_build\b
ild_dm\rmi_server_files\lib
model.data_model.ActivateDataManager
Can anyone tell me why the application can not find
the XMLEntities.res inside jar?try loading the resources as a InputStream
something like :
InputStream is = NameOfLoadingClass.class.getClassLoader().getResourceAsStream("XMLEntities.res");
Hope this might help you in some way.

Similar Messages

  • Problem in reading no. of files and writing into a single file

    Hi,
    Iam with Problem in reading no. of files and writing into a single file....
    Iam reading no. of files stored in local directory.......
    Iam able to read and print the data in files successfully....but while writing..only first file is being written...and the next files are not written in my output file...
    plz tell me my mistake....I hope Iam doing some mistake while writing into file...PLz help.....
    Basically my code structure is like this....
    import java.io.*;
    import java.util.regex.*;
    import java.util.*;
    import java.text.*;
    import org.apache.poi.poifs.filesystem.POIFSFileSystem;
    import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    import org.apache.poi.hssf.usermodel.HSSFSheet;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    import org.apache.poi.hssf.usermodel.HSSFCell;
    class Writing {
    public static void main(String args[]) throws Exception {
              FileOutputStream fileOut = new FileOutputStream("ServerResult.xls"); //my output file
              int counter = 1;
              File dir = new File("C:/Perform/ServerLogs");
              String[] children = dir.list();
              if( children == null)
                   System.out.println("The Directory mentioned does not exist");
              else {
                   for (int fileNo = 0; fileNo < children.length; fileNo++ ) {        //Files iteration starts
                        String filename = children[fileNo];
              File logFile = new File(filename);
    FileReader logFileReader = new FileReader(logFile);
    BufferedReader logReader = new BufferedReader(logFileReader);
    StringBuffer sBuf = new StringBuffer(5000);
              HSSFWorkbook wb = new HSSFWorkbook();          
              HSSFSheet sheet = wb.createSheet();
              HSSFRow rowTitle;
              HSSFRow rowReq;
              HSSFRow rowRes;
    String aLine = null;
    boolean skip = false;
    boolean readed = false;
    boolean initReq = false;
              boolean flag = false;
    long requestTime = 0;
    long responseTime = 0;
    long recdTime = 0;
    long sentTime = 0;
              long hasTime = 0;
              long presentTime = 0;
              int hasCalls = 0;
    Pattern startMessage = Pattern.compile("^<MESSAGE.*ID=\".*_"+args[0]+"\".*", Pattern.DOTALL);
    Pattern requestMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"RequestMsg.\".*ID=\".*_"+args[0]+"\".*<ActName>(.*)</ActName>.*", Pattern.DOTALL);
    Pattern requestMessage1 = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"RequestMsg.\".*ID=\".*_"+args[0]+"\".*<Svc id=\"(.*)\">.*", Pattern.DOTALL);
    Pattern responseMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"ResponseMsg\".*ID=\".*_"+args[0]+"\".*", Pattern.DOTALL);
    Pattern initMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"HostConnInit\".*ID=\".*_"+args[0]+"\".*", Pattern.DOTALL);
    Pattern initResMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"ResponseMsg\".*ID=\"null\".*", Pattern.DOTALL);
    Pattern initResIDMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"ResponseMsg\".*ID=\"null\".*<IATA>"+args[0]+"</IATA>.*", Pattern.DOTALL);
              Pattern sentMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"DCMsgSentInfo\".*ID=\".*_"+args[0]+"\".*", Pattern.DOTALL);
              Pattern rcvdMessage = Pattern.compile("^<MESSAGE.*TS=\"(.*)\" CATEGORY=\"DCMsgRcvdInfo\".*ID=\".*_"+args[0]+"\".*", Pattern.DOTALL);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    DecimalFormat dcf = new DecimalFormat("########.##");
    String actName = "";
              if (fileNo ==0)
              rowTitle = sheet.createRow((short)0);
              rowTitle.createCell((short)0).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)0).setCellValue("Req/Res");
              rowTitle.createCell((short)1).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)1).setCellValue("Action");
              rowTitle.createCell((short)2).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)2).setCellValue("Server Time(in ms)");
              rowTitle.createCell((short)3).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)3).setCellValue("Request Vs Response Time in Server(in ms)");
              rowTitle.createCell((short)4).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)4).setCellValue("Time Taken By HAS/HOST(in ms)");
              rowTitle.createCell((short)5).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)5).setCellValue("No. of HAS calls");
              rowTitle.createCell((short)6).setCellType(HSSFCell.CELL_TYPE_STRING);
              rowTitle.createCell((short)6).setCellValue("Data Size");
              //wb.write(fileOut);
    while((aLine=logReader.readLine()) != null) {
    if(aLine.startsWith("<MESSAGE TYPE=\"EVENT\"")) {
    Matcher m = startMessage.matcher(aLine);
    if(m.find()) {
    sBuf.setLength(0);
    sBuf.append(aLine);
    skip = false;
    initReq = false;
    m = initMessage.matcher(aLine);
    if(m.find()) {
    initReq = true;
    } else {
    if(initReq) {
    m = initResMessage.matcher(aLine);
    if(m.find()) {
    sBuf.setLength(0);
    sBuf.append(aLine);
    skip = false;
    } else if(aLine.startsWith("</MESSAGE>")) {
    if(!skip) {
    sBuf.append(aLine);
    readed = true;
    } else if(!skip){
    sBuf.append(aLine);
    if(!skip && readed) {
    String tempStr = sBuf.toString();
    if(tempStr.length() > 0) {
    boolean reqMatched = false;
    Matcher m = null;
    if(initReq) {
    m = initMessage.matcher(tempStr);
    actName = "Intialization";
    } else {
    m = requestMessage.matcher(tempStr);
    String time = "";
    if(m.find()) {
    reqMatched = true;
    for (int i=1; i<=m.groupCount(); i++) {
    String groupStr = m.group(i);
    if(i == 1) {
    time = groupStr;
    } else if(i == 2) {
    actName = groupStr;
    } else if(!initReq){
    m = requestMessage1.matcher(tempStr);
    if(m.find()) {
    reqMatched = true;
    for (int i=1; i<=m.groupCount(); i++) {
    String groupStr = m.group(i);
    if(i == 1) {
    time = groupStr;
    } else if(i == 2) {
    actName = groupStr;
    if(time.length() > 0 ) {
    try{
    requestTime = sdf.parse(time).getTime();
    }catch(Exception ex){}
    System.out.println("Request,"+actName+","+time+",,,,"+dcf.format(((double)time.length()/1024.0))+"K");
                                  //bw.write("Request,"+actName+","+time+",,,,"+dcf.format(((double)time.length()/1024.0))+"K");
                                  String reqDataSize = dcf.format(((double)time.length()/1024.0))+"K" ;
                                  rowReq = sheet.createRow((short)counter);
                                       rowReq.createCell((short)0).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)0).setCellValue("Request");
                                       rowReq.createCell((short)1).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)1).setCellValue(actName);
                                       rowReq.createCell((short)2).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)2).setCellValue(time);
                                       rowReq.createCell((short)3).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)3).setCellValue("");
                                       rowReq.createCell((short)4).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)4).setCellValue("");
                                       rowReq.createCell((short)5).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)5).setCellValue("");
                                       rowReq.createCell((short)6).setCellType(HSSFCell.CELL_TYPE_STRING);
                                       rowReq.createCell((short)6).setCellValue(reqDataSize);
                                       counter = counter +1;
                                       System.out.println("counter is "+counter);
                             Matcher l = sentMessage.matcher(tempStr);
                             Matcher k = rcvdMessage.matcher(tempStr);
                   if(l.find()) {
                                            for (int i=1; i<=l.groupCount(); i++) {
         String groupStr2 = l.group(i);
    try{
    sentTime = sdf.parse(groupStr2).getTime();
    }catch(Exception ex){}
                        if(k.find())
                                                 for(int j=1;j<=k.groupCount(); j++) {
                                                 String groupStr1 = k.group(j);
                                                 try{
    recdTime = sdf.parse(groupStr1).getTime();
    }catch(Exception ex){}
                                                 presentTime = (recdTime - sentTime);
                                                 hasTime = hasTime + presentTime;
                                                 hasCalls = hasCalls +1;
    if(!reqMatched) {
    if(initReq) {
    m=initResIDMessage.matcher(tempStr);
    } else {
    m=responseMessage.matcher(tempStr);
    if(m.find()) {
    for (int i=1; i<=m.groupCount(); i++) {
    String groupStr = m.group(i);
    try{
    responseTime = sdf.parse(groupStr).getTime();
    }catch(Exception ex){}
                                                 String resDataSize = dcf.format(((double)tempStr.length()/1024.0))+"K" ;
                                                 rowRes = sheet.createRow((short)(counter));
                                                 rowRes.createCell((short)0).setCellType(HSSFCell.CELL_TYPE_STRING);
                                                 rowRes.createCell((short)0).setCellValue("Response");
                                                 rowRes.createCell((short)1).setCellType(HSSFCell.CELL_TYPE_STRING);
                                                 rowRes.createCell((short)1).setCellValue(actName);
                                                 rowRes.createCell((short)2).setCellType(HSSFCell.CELL_TYPE_STRING);
                                                 rowRes.createCell((short)2).setCellValue(groupStr);
                                                 rowRes.createCell((short)3).setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                                                 rowRes.createCell((short)3).setCellValue((responseTime - requestTime));
                                                 rowRes.createCell((short)4).setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                                                 rowRes.createCell((short)4).setCellValue(hasTime);
                                                 rowRes.createCell((short)5).setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                                                 rowRes.createCell((short)5).setCellValue(hasCalls);
                                                 rowRes.createCell((short)6).setCellType(HSSFCell.CELL_TYPE_STRING);
                                                 rowRes.createCell((short)6).setCellValue(resDataSize);
                                                 hasTime = 0;
                                                 hasCalls = 0;
                                                 counter = counter + 1 ;
    sBuf.setLength(0);
    readed = false;
              wb.write(fileOut);
              } // End of for (int fileNo = 0; fileNo < children.length; fileNo++ )
    }     //End of else
              fileOut.close();
    } //End of public static void main
    } // End of Class

    First of all, use [code]-tags to make your code readable, please.
    I didn't do a complete inspection of your code (because it's too much and unreadable as it is) and I don't know POI, but creating a new HSSFWorkbook for each input file sounds fishy to me ... try re-using the workbook and just creating a new sheet in each iteration.

  • Accessing resource files inside Jar using Fat Jar Eclipse plugin

    Hi,
    I want to develop single JAR file that uses a set of other JAR libraries. I am using Fat Jar Eclipse plugin. It works fine. However, I have problem to access resources files (i.e. rdf file) using relative path from my classes. Is there any idea how can I pack, set classpath and use relative path in order to make it works.
    Thanks
    Zoran

    I have solved this problem. The problem was in a way how I have trying to access it. It should be like:
    URL fileURL = this.getClass().getResource("resource/myFile.rdf");
    Zoran

  • Problem in reading an Image file from a Output Stream.

    I am having problem reading a JPEG file. Actually i am sending JPEG file using UDP from the client. I am using this code to convert to a byte array to transmit the file:
    DataInputStream inStream = new DataInputStream(new FileInputStream("src/Bgamex.jpg"));
    String str1 = inStream.toString();
    byte[] bindata = new byte[65500];
    bindata = str1.getBytes();
    On the server side, I am using these lines to convert the bytes to a file again but it seems to be that its not working. Its making file but with a bigger size & like garbage in it, showing nothing:
    byte[] buf = new byte[65500];
    // receive request
    DatagramPacket packet = new DatagramPacket(buf, buf.length);
    socket.receive(packet);
    buf = packet.getData();
    java.io.OutputStream fos = new java.io.FileOutputStream("Bga.jpg");
    fos.write(buf);
    Could somebody lemme know the problem in converting the file.
    Thanx.

    I propose you to perform this simple test to see by yourself:     final String BIN_FILENAME = "somebytes.bin";
        byte[] bin = {5, 4, 3, 2, 1};
        FileOutputStream out = new FileOutputStream(BIN_FILENAME);
        out.write(bin);
        out.flush();
        out.close();
        byte[] bindata;
        DataInputStream in1 = new DataInputStream(new FileInputStream(BIN_FILENAME));
        String str = in1.toString();
        in1.close();
        bindata = str.getBytes();   
        System.out.print("Bytes read with in1>");
        for (int i=0; i<bindata.length; i++) System.out.print(bindata);
    System.out.println();
    FileInputStream in2 = new FileInputStream(BIN_FILENAME);
    bindata = new byte[65505];
    int bread = in2.read(bindata, 0, in2.available());
    in2.close();
    System.out.print("Bytes read with in2>");
    for (int i=0; i<bread; i++) System.out.print(bindata[i]);
    System.out.println();

  • Problem in reading the excel file path in WINDOWs machine from UNIX environ

    Hello friends,
    My requirement is to read each row of the excel sheet and sent that row to the database. I have implemented it by using jxl and apache poi framework. locally in my WINDOWS machine it is working fine..
    But when i deploy the code in UNIX machine. My application runs on a Unix server , trying to read the excel file in WINDOWS environment. I am not able to retrieve the file path. for ex : C:\Documents and Settings\sabbanik\My Documents\KARUNAKAR\excel.xls
    I am getting error in this line
    workbook = Workbook.getWorkbook(filepath)
    Error message : input file not found.
    Thanks in advance..

    You said: I am getting error in this line workbook = Workbook.getWorkbook(filepath) >
    Based on this, I will assume you are trying to use OLE to access information about the Excel file. As mentioned by Andreas, your code will be executing on the server (Unix) and since Excel isn't on the server (and cannot be) an error will result. OLE can only be used in Windows environments (client or server). To access client side OLE calls and content, you need a java bean and Excel installed on the client machine. Oracle provides WebUtil as an option to writing your own Java Bean. To use this, you will need to be running Forms 10.1.2 or newer. Details can be found here along with a demo:
    http://www.oracle.com/technetwork/developer-tools/forms/webutil-090641.htm

  • Reading an xml file from jar

    I have an xml file in a jar file other than the class that needs to read it. Most of teh posts I've seen reccomend using class.getResource to get access to the jar, but since the file is in a different jar this wont work.
    I load classes using URLClassLoader and explicitely access the class I need from a specific jar by creating a url thusly....
    jar:file:/" + workingDirectory + "/folder/jarfile.jar!/specificfolder/specificfile.class"
    Is there a similar thing for reading an xml file for a jar?

    Have you tried:
    "jar:file:/" + workingDirectory + "/folder/jarfile.jar!/specificfolder/specificfile.xml"
    ;o)
    V.V.

  • How to raplace resource files in jar file by other files?

    Can I replace resource files (ex: some jpeg file which is in the jar file) when midlet execute on the phone. Is it possible?
    Usualy, we use getResourceAsStream(filename) to get resource data as stream.
    Is there some API function like 'setResource(filenmae,stream)' ??
    Assume that I have a javaME application which displays some image in the jar file.
    It is different from general image viewr program because it can display only
    image file in the jar file (it means image file is resource file of java applcation).
    In other words, when application executes, It shows always same image at first.
    but I want that user can change image displayed if user wnat to do. I want to embed
    authoring function into application. So user can replace resource file by other image files on the phone.
    How to do that?

    I already told you, you CAN'T replace resources in a jar file.
    [http://forums.sun.com/thread.jspa?threadID=5334325]
    Look into using rms to save content on a mobile device.
    Now do you have anything else you want to ask?
    db
    edit And it's also rude to repost the question here without posting a response on the other topic you started.
    Edited by: Darryl.Burke

  • Problem with reading from bin file into Vector

    What am I doing wrong? It works fine to write the vector to the bin file and then read from it. But if I try just to read from the file it wont work.
    Does anybody has any good advice to give when it comes to reading data form a bin file??
    import javax.swing.*;
    import java.util.*;
    import java.io.*;
    class Binaerfil
         public static void main (String [] args) throws IOException, ClassNotFoundException{
              ObjectOutputStream utFil = new ObjectOutputStream (new FileOutputStream("HighScoreLista.bin"));
              int po = 50;
              Spelare s;
              Spelare s1, s2, s3, s4, s5,s6,s7,s8,s9,s10;
              String f�rNamn;
              Vector v = new Vector();
              s1 = new Spelare("Mario", 100);
              s2 = new Spelare("Tobias",90 );
              s3 = new Spelare("Sanja", 80 );
              s4 = new Spelare("Marko", 70 );
              s5 = new Spelare("Sofia", 60 );
              s6 = new Spelare("Kalle", 50 );
              s7 = new Spelare("Lisa", 40 );
              s8 = new Spelare("Pelle", 30 );
              s9 = new Spelare("Olle", 20 );
              s10 = new Spelare("Maria",10 );
              v.add(s1);
              v.add(s2);
              v.add(s3);
              v.add(s4);
              v.add(s5);
              v.add(s6);
              v.add(s7);
              v.add(s8);
              v.add(s9);
              v.add(s10);
              System.out.println ("Before writing to file");
              System.out.println(v);
              //Write to file
              utFil.writeObject (v);
              utFil.close();
         ObjectInputStream inFil = new ObjectInputStream (new FileInputStream("HighScoreLista.bin"));     
              v =(Vector) inFil.readObject();
         System.out.println (v);
              inFil.close();
    }

    Because what you are writing to the file is a vector, that is all you can get out. You are actually reading a single Object from the file which you can cast to a Vector, from which you can access the data stored inside. If you want to read the Spelare instances from the file, you will have to save them individually to the file. You will have to implement Serializable and look up the API to do that.

  • Help! Problem with reading objects from file

    I wrote a "Library" program for an assignment, and one of the requirements is that the library store all of its information to file upon exit, and reload this information from file when run.
    Well, the writing to file part is working. I'm using a FileOutputStream object and an ObjectOutputStream object. I can tell from the file size of the .dat file that information is going into it.
    But what I can't do is read from file. For that, I'm using a FileInputStream and an ObjectInputStream. I keep getting this exception:
    java.io.EOFException
         at java.io.DataInputStream.readInt(Unknown Source)
         at java.io.ObjectInputStream$BlockDataInputStream.readInt(Unknown Source)
         at java.io.ObjectInputStream.readInt(Unknown Source)
         at Library.readDataFromFile(Library.java:350)
         at Library.<init>(Library.java:63)
         at LibraryDriver.main(LibraryDriver.java:6)I looked this exception up and it says it's thrown when a data input stream unexpectedly ends....But I am instantiating the input streams just before I try to read from file:
                            fileInStream = new FileInputStream(libraryFile);
                   objInStream = new ObjectInputStream(fileInStream);
                   Object[] objectArray = new Object[objInStream.readInt()];Both input streams have methods that "return the number of bytes that can be read from this file input stream without blocking". Just for kicks, I tried writing that number to the console.
    For the FileInputStream, I get 404 bytes.
    For the ObjectInputStream, I get 0 bytes.
    So I guess it's a problem with the ObjectInputStream? Anyone have any suggestions as to how I can fix this, please?

    Yep, here's the relevant code from the writeToFile() method:
                          for (int i = 0; i < libraryAuthors.length; i++) {
                        currentAlphaAuthorList = libraryAuthors;
                        for (int j = 0; j < currentAlphaAuthorList.size(); j++) {
                             currentAuthor = (Author) currentAlphaAuthorList.get(j);
                             objOutStream.writeObject(currentAuthor);
                   objOutStream.flush();
                   objOutStream.close();

  • Problems on reading PCM into digital form

    Hi,
    I'm now on a project doing heart rate detection.
    Due to the project just started, therefore I do not got any device to measure my own heart rate, but I will be making up some PCM(analog) data, and try to read that into digital form and give me results of the heart rate.
    I'm not sure am I on the right track now or not,
    what I'm doing now is trying to convert a ".wav" into bytes array, then it should give me some data, however, I'm not sure how to relate that data into heart rate.
    Please leave me any comment if u think it might help please.
    Thanks,
    till

    I'm not too sure what should be the .wav should be, however, according to this acticle I got it from the web:
    _2.1 Signal acquisition_
    ECG signal frequency content lies between about 0.05Hz and
    500Hz and has amplitude of few mV. The acquisition is provided
    to be performed in three different ways: (i) using direct electrode
    measurements, (ii) using ECG equipment with analogous output;
    and (iii) using ECG equipment with digital output. For the first
    two cases, a sampling rate of 8 kHz is assumed. In the third case,
    the acquired discrete signals are accordingly resampled.
    _2.2 Modulation_
    The bandwidth of the phone’s voice channel is limited to the
    range 300Hz-3300Hz. The signal amplitude at the microphone
    input should not exceed 100mV. Modulation is performed through
    multiplication with carrying sinusoidal signals. Five 500Hz-wide
    channels are packed within the 500Hz-3000Hz band. The
    resulting signal is appropriately refined in amplitude and directed
    to the modulator’s output.
    _2.3 Digitizing, storing and sending_
    The complex signal is band-limited to 3300Hz. Therefore, a
    standard sampling frequency of 8 kHz is used for its digitization.
    A JAVA application performs that and in order to store the signal
    intact, the signal is recorded in a lossless format such as pulsecode
    modulation (PCM). The WAV audio file format implements
    PCM and is used to store the recorded modulated ECG signals.
    Once stored, the signals can be visualized, processed and sent by
    the mobile phone.
    Mobile phone’s firmware is accessible by programming
    languages as C++ and JavaTM. Most mobile phones support
    JavaTM runtime called Kilobyte Virtual Machine (KVM) [6]. This
    language provides the ability to build a GUI application that could
    support all the stages of recording, storing and transmitting of the
    ECG signal. JSR-135 contains libraries of JavaME, which are
    useful for capturing audio from the microphone's port of a mobile
    phone. The above mentioned platform was used to create the
    application software.
    _2.4 Demodulation_
    The procedure of demodulation is performed at the physician’s
    phone, following the reverse track of modulation. A digital band
    pass filter is used to separate the spectra, corresponding to the
    individual ECG signals. The filtered signal was then multiplied by
    the corresponding carrier frequency and filtered with a low pass
    filter, resulting in the original signal. The demodulated signals can
    be stored in separate WAV files in the physician’s phone.
    _2.5 Matlab simulations_
    In order to prove the principal feasibility of the approach, the
    signal acquisition, processing and transmission procedures were
    simulated in MATLAB. Five preliminary recorded ECG signals
    were directly loaded and used. The signals acquisition parameters
    were: 8-bit values, sampling rate of 250Hz and duration – 10S.
    Modulation and demodulation were programmed and performed
    in a numerical way. Modulation was done by multiplication of the
    ECG signals with carrying sinusoidal signals of frequencies
    500Hz, 1000Hz, 1500Hz, 2000Hz, and 2500Hz. The
    demodulation included first separating the spectrum of each
    individual signal with the help of 4-th order 400Hz-wide bandpass
    Butterword filters centered on the corresponding carrying
    frequency. Next the filtered signals were multiplied with the same
    carrier signals and eventually filtered with a low pass 4-th order
    Butterworth filter (fc=200Hz).
    btw, the system need to be implement into Symbian phone at the end,
    but I'm just now testing on the PC atm =)
    according to this article, what kind of wav I should be using ??
    thanks a lot!!!

  • Problem in Reading a .PDF file

    HI Friends,
    I am reading a .pdf file from within java program using its java.io package.
    I am able to read the file, but when I print the line read from file on to the screen, it all garbage. Its not in readable characters.
    I guess its reagrding mismatch in Charcter Sets of original file and the stream with which I m reading the file.
    So,if u know the solution plz suggest me.

    Hello Simple@java
    Here's an exemple of a class that opens the File "rapport.pdf" located at the same place as the class.
    Of course AcroRd32.exe is the name of Acrobat Reader which allows to read pdf files. You can get it on : adobe.com(http://www.adobe.com/products/acrobat/readstep2.html)
    You will change "rapport.pdf" by the name of your pdf file.
    Then execute "test()".
    * Open the file "rapport.pdf"
    public class test
         public test()
              Runtime a = Runtime.getRuntime();
              try
                   a.exec("AcroRd32.exe rapport.pdf");               
              catch (Exception e)
                   System.out.println(e.getMessage());
    Good luck !

  • Problem with reading from a file

    `HI,
    i am trying to read from a text file... using following piece of code
    try{               
                   BufferedReader in = new BufferedReader( new FileReader(fileName), 100000);
                   while (in.readLine() != null)
                        temp = in.readLine();
                   in.close();
                   in = null;
                   } catch(Exception e) {System.err.println(e); }          
                   System.out.println(temp);     
    text contains almost 7500 words...
    but when i run this piece of code... output i got is NULL
    ... i don't know what i am doing wrong...
    any suggestions
    <Thanx in advance >

    while (in.readLine() != null)Right here, you are reading in the file, but you don't store the content.
    temp = in.readLine();By the time you reach here, you have already read in the whole file, so there is nothing left to read. That's why temp is assigned null

  • Problem with reading from DAT file. FileNotFound exception

    Can't seem to find the issue here. Two files, one (listOfHockeyPlayers) reads from a DAT file a list of players. The other (HockeyPlayer) has just the constructor to make a new hockey player from the read data.
    import javax.swing.*;
    import javax.swing.event.*;
    import java.util.*;
    import java.awt.*;
    import java.io.*;
    public class ImportHockeyPlayers
    private ArrayList<HockeyPlayer> listOfHockeyPlayers = new ArrayList<HockeyPlayer>();
    public ImportHockeyPlayers(String fileName)
      throws FileNotFoundException
      try
       Scanner scan = new Scanner(new File(fileName));
       while (scan.hasNext())
        //Uses all the parameters from the HockeyPlayer constructor
        String firstName = scan.next();
        String lastName = scan.next();
        int num = scan.nextInt();
        String country = scan.next();
        int dob = scan.nextInt();
        String hand = scan.next();
        int playerGoals = scan.nextInt();
        int playerAssists = scan.nextInt();
        int playerPoints = playerGoals + playerAssists;
        //listOfHockeyPlayers.add(new HockeyPlayer(scan.next(),scan.next(),scan.nextInt(),scan.next(),scan.nextInt(),scan.next(),
         //scan.nextInt(),scan.nextInt(),scan.nextInt()));
      catch(FileNotFoundException e)
       throw new FileNotFoundException("File Not Found!");
    public String toString()
      String s = "";
      for(int i = 0; i < listOfHockeyPlayers.size(); i++)
       s += listOfHockeyPlayers.get(i);
      return s;
    public class HockeyPlayer
    private String playerFirstName;
    private String playerLastName;
    private int playerNum;
    private String playerCountry;
    private int playerDOB;
    private String playerHanded;
    private int playerGoals;
    private int playerAssists;
    private int playerPoints;
    public HockeyPlayer(String firstName, String lastName, int num, String country, int DOB,
      String hand, int goals, int assists, int points)
      this.playerFirstName = firstName;
      this.playerLastName = lastName;
      this.playerNum = num;
      this.playerCountry = country;
      this.playerDOB = DOB;
      this.playerHanded = hand;
      this.playerGoals = goals;
      this.playerAssists = assists;
      this.playerPoints = goals + assists;
    DAT File
    Wayne Gretzky 99 CAN 8/13/87 R 120 222
    Joe Sakic 19 CAN 9/30/77 L 123 210These are all in early development, we seem to have the idea down but keep getting the odd FileNotFound exception when making an object of the ImportHockeyPlayers class with the parameter of the DAT file.
    We might even be on the wrong track with an easier way to do this. To give you an idea of what we want to do...read from the file and be able to pretty much plug in al lthe players into a GUI with a list of the all the players.
    Thanks for your time.

    Thanks for the tip on the date format...good to
    know.
    public static void main(String[] args)
    GUI gui = new GUI();
    ImportHockeyPlayers ihp = new
    ImportHockeyPlayers("HockeyPlayers.dat");
    }It's just being called in the main.
    Throws this error:
    GUI.java:39: unreported exception
    java.io.FileNotFoundException; must be caught or
    declared to be thrown
    ImportHockeyPlayers ihp = new
    ImportHockeyPlayers("HockeyPlayers.dat");
    ^This error is simply telling you that an exception may occur so you must enclose it in a try catch block or change the main method to throw the exception as follows
    public static void main(String[] args) throws  
                          java.io.FileNotFoundException {
         GUI gui = new GUI();
         ImportHockeyPlayers ihp = new
         ImportHockeyPlayers("HockeyPlayers.dat");
    }or
    public static void main(String[] args) {
         GUI gui = new GUI();
         try {
              ImportHockeyPlayers ihp = new
              ImportHockeyPlayers("HockeyPlayers.dat");
         catch (FileNotFoundException e) {
              System.out.println("error, file not found");
    }I would reccomend the second approch, it will be more helpful in debugging, also make sure that the capitalization of "HockeyPlayers.dat" is correct
    hope that helps

  • Unable to read a resources file from my page

    Hi,
    I am trying to read a file from the project resources and I can't have access to the physical file. I have the following code in my page:
    javax.faces.context.ExternalContext ec = this.getExternalContext();
    URL url = ec.getResource("/resources/displayPassengers.xsl");
    InputSource inputSourceXSL = new InputSource(url.toExternalForm());
    InputStream inpStreamXSL = null;
    if (inputSourceXSL.getByteStream() != null) {
    log("Loading xml file: " + url.toExternalForm());
    inpStreamXSL = inputSourceXSL.getByteStream();
    } else {
    log("Unable to extract URL from Page context: WEB-INF/displayPassengers.xsl");
    The url is not null.
    The inputSourceXSL is not null and inputSourceXSL.getByteStream() is always null.
    Please let me know how to access the file.
    Rgrds.

    this should work
    InputSource inputSourceXSL = new InputSource(url.openStream());

  • Problem in reading from the File

    Hi,
    I have a dataset.txt file which is as follows:
    2
    4
    1 2 3 4
    2 3 4 5
    3 4 5 6now that I need the value that is present in the 1st line of the file(ie;2) and value present in the 2nd line of the file(ie;4), upon that i'll be reading the data into an array.
    for this task of mine to accomplish , i'm using the following code
    String line_1;
    String line_2;
              int first_line,second_line;
              DataInputStream dis1 =null;
              DataInputStream dis2 =null;
              System.out.println("Print this");
              try
                   File f1=null;
                   f1 = new File ("dataset.txt");
                   File f2=null;
                  f2 = new File ("dataset.txt");
                 FileInputStream fis1 = new FileInputStream(f1);
                 FileInputStream fis2 = new FileInputStream(f2);
                 dis1 = new DataInputStream(fis1);
                 dis2 = new DataInputStream(fis2);
                           BufferedReader line1 = new BufferedReader(new InputStreamReader(dis1));
                      line_1=line1.readLine();
                      first_line=Integer.parseInt(line_1);
                      System.out.println("Value of First_line is:     "+first_line);
                      BufferedReader line2 = new BufferedReader(new InputStreamReader(dis2));
                      line_2=line2.readLine();
                      second_line=Integer.parseInt(line_2);
                      System.out.println("Value of Second_line is:     "+second_line);
    }//end of try
    catch(Exception e)
    {e.printStackTrace();}The problem here I'm having is, when i'm printing I'm getting the follow result
    Value of First_line is:2
    Value of Second_line is:2Instead of printing the value of Second_line as 4, it is printing 2.
    Why is this happening?
    Any kind of response is appreciated.
    Thanks is advance

    You dont have to make 2 data stream objects of the file.
    To read two lines you can just do with it object
    BufferedReader line1 = new BufferedReader(new InputStreamReader(dis1));and just call readLine( ) method twice
    line_1=line1.readLine();
    line_2=line1.readLine();

Maybe you are looking for

  • Converted Crystal Report Not Executing in Info View

    We are in the process of testing BOXI3.1 sp2 fix pack 2.8. The problem we are having was not occurring in BOXI rel2. After saving a Crystal Report developed with version 11.5.0.313 using CR2008, the report was run successfully within Crystal Reports.

  • CS4 suddenly stopped working

    I installed CS4 7 months ago on a brand new laptop and it has worked perfectly until a few weeks ago when it suddenly quit launching.  It will only open partially--with the left sidebar showing and is unusable.  I tried uninstalling and reinstalling

  • Please help--Ipod says DO NOT DISCONNECT and I cant stop it-

    I wish there wasd someone I could talk to to walk me thru this.I was updating software, connected ipod and now the update is frozen, and I can't disconnect ipod. Help - I don't know what to do.

  • RS232 Input and Output in the same time

    Hello I have problem with rs232.  I read information from my power supply by RS232 Input:  Expected string: 1923456789<CR>OK<CR> Channel 0  Measurement data request: GETD00\r  Measurement data format: 4a Channel 1  Measurement data request: (empty)  

  • ABAP proxy call to eBay webservice

    Hi, I'm trying to configure an ABAP proxy call to the eBay SOAP web services using ECC6 (SP14). Has anyone had any experience they can share on how to configure the security for the proxy endpoint in SOAMANAGER to use the ebay services? Thanks Tim