Reading and Writing to files in JARs

I'm making a card game (TriPeaks). I need to store the scores for the users in files. Everything worked fine until I packaged it into a JAR. I tried using getClass().getResource(fileName); and then converting the URL to a URI to create the File object. That gave me an error saying the URI wasn't hierarchical.
So I Googled around and found that I can use:
InputStream is = getClass().getResourceAsStream(fileName);
try {
    BufferedReader in = new BufferedReader(new InputStreamReader(is));
    //read the file, etc.
    is.close();
catch (IOException eIO) { }That works both in and out of the JAR. However, I still can't write the scores to the files. I know that you can write to a file inside a JAR because I created another program that writes its settings to a file. However, that program has its settings file in the same folder (the root of the JAR) as the .class file in the JAR. The scores, however, are in a subfolder in the JAR file.
How would I write to the files in the subfolder in the JAR file?

Vetruvet wrote:
Why wouldn't there be such a useful feature in the API?Because it's extremely difficult to implement. Let me give you a quick description of how a jar file is structured. It uses the ZIP format that's been around for about 30 years now. The contents of a ZIP archive are arranged like this:
- Header information
- Compressed file #1
- Compressed file #2
- ... and so on ...
- Directory with pointers to offsets of the compressed files.
So when you want to get a file from the archive, you go to the end and find the directory. You search it for the file you want to get and find its offset, then you go there and decompress the file that's there.
Now consider trying to update one of these files. The compressed version of the new file may well differ in size from the existing file in the archive. So you'd have to do something intrusive and expensive like moving all the files after it, including the directory, or just adding it after the last compressed file and moving the directory.
And doing this would mess up things in the case where another thread or process or object (e.g. a URLClassLoader) was already using the archive.
It just isn't practical. So consider JAR and ZIP archives as read-only. That's what they were designed for in the first place anyway.

Similar Messages

  • File importer detected an inconsistency in the file stucture of (file name). Reading and writing this file's metadata (XMP) has been disabled.

    I have duplicated a project to work on another computer. The project opens fine but when I import new footage/audio files I get this message. "File importer detected an inconsistency in the file stucture of (file name). Reading and writing this file's metadata (XMP) has been disabled." Then I can't play my timeline and Premier Pro crashes.  I have to force quit and restart my computer to continue working. What does this error really mean? How do you rectify?
    Our workflow requires that we duplicate projects to make updates because we are frequently revising but need to keep original project unchanged and intact.

    I have a similar issue and message , but occurs when I import AVI clips from OnLocation CS4 to Premier Pro CS4.

  • Reading and writing to file , getting null when i try to  read file content

    i start by apologizing incase i have posted this question in the wrong forum
    i am trying to iterate through a directory tree and pick all the subdirectories and put them in an arraylist . on the other hand , i am picking all the files and putting them in a different arraylist . After that i iterate through the arraylist , pick a folder , create a file in it search for all the files of the same type in its subfolders and write them to the newly created file
    The problem i am running into is i i can't read the files and hence i can't write to the file .
    My directory tree is in the format
    c:\KPCData\\01\01\01\01\01\ file1_type1
    c:\KPCData\\01\01\01\01\02\ file2_type1
    where one one of the types is "covers" . i know this could be asking too much but i am at my tethers end , could someone please have a look at the code and tell me where i might be going wrong . you could zero in on the part where i have ************ before the a line of code thank you package directories;
    import java.io.*;
    import java.util.*;
    public class Directories {
    private static  ArrayList direcs= new ArrayList();
    private static  ArrayList census= new ArrayList();
    private static ArrayList vagrant= new ArrayList();
    private static ArrayList hotel= new ArrayList();
    private static ArrayList emigrant= new ArrayList();
    private static ArrayList traveller= new ArrayList();
    private static ArrayList longform= new ArrayList();
    private static ArrayList cover= new ArrayList();
    private static String parentPath = null;
    private static File mycover = null;
    private static File mytravel = null;
    private static File myemigrant = null;
    private static File mylong= null;
    private static File myinstitution = null;
    private static File myvagrant = null;
    private static BufferedReader in;
    private static BufferedWriter out;
    private static String read,toread;
    //function for listing the folder contents
    class compareDirs implements Comparator
    public int compare(Object one, Object two)
         int val=0;
         File file1 = (File)one;
         File file2= (File)two;
         String name1 = file1.toString();
         String name2= file2.toString();
         if (name1.length()==name2.length())
         val= name1.compareTo(name2);
         else
              if( name1.length()>name2.length())
                   val=-1;
              if (name1.length()<name2.length())
                   val=1;
         return val;
    private  ArrayList recurs(File dir,File file) throws IOException
         File []files=dir.listFiles();
         for(int index=0;index<files.length ;index++)
              if(files[index].isDirectory())
                   recurs(files[index],file);          
              }//if
              else
                  census.add(files[index]);     
         }//for index
         return census;
    } //recurs
    //function for determining the number and paths of the folders
    private ArrayList numDirs(File dirs)
         File []files=dirs.listFiles();
         for(int index=0;index<files.length ;index++)
              if(files[index].isDirectory())
                   if (direcs.contains(files[index])==false)
                   direcs.add(files[index]);
                   numDirs(files[index]);     
              }//if
         }//for index
         return direcs;
    public static void main(String[]args) throws IOException
              File myfile = new File("C:\\KPCData");
         File myfile2= new  File("C:\\KPCData\test.txt");
         Directories dir = new Directories();
         if (myfile.isDirectory())
         ArrayList myList=dir.recurs(myfile,myfile2);
         ArrayList mydir1 = dir.numDirs(myfile);
        ArrayList mydirs = new ArrayList();
        mydirs.add(mydir1.get(0));
         for (int x=0;x<mydir1.size();x++)
         {  int count=0;
              for (int y=0;y<mydirs.size();y++)
                   if (x==y)
                        count++;
              if (count<1)
                   mydirs.add(mydir1.get(x));
         Collections.sort( mydirs,dir.new compareDirs() );     
            for(int index1 =0 ;index1<mydirs.size();index1++)//print out directories
              File mydir=(File)mydirs.get(index1);
              File directory= (File)mydirs.get(index1);
              if(!mydir.getPath().contains("00"))//// if not leave node  create files for each file type
                   String name1 =mydir.getPath();
                   ArrayList ray=new ArrayList();
                   String name="K";
                 for (int index=0;index<name1.length();index++ )
                          if (name1.charAt(index)!='\\'&&name1.charAt(index)!='C'&&name1.charAt(index)!=':'&&name1.charAt(index)!='K'&&name1.charAt(index)!='P'&&name1.charAt(index)!='D'&&name1.charAt(index)!='a'&&name1.charAt(index)!='t')
                       name =name+(String.valueOf(name1.charAt(index)));
              // create a string
                  name= name.substring(1);
                   String trial = name+"_cover.dat";
                   mycover = new File ( mydir,trial);
                     if (mycover.exists()) {
                          mycover.delete();
                          mycover.createNewFile();
                      } else {
                           mycover.createNewFile();
                     String addit = mydir.getParent().toString();
                    mylong = new File (addit+"\\_long.dat");
                    if (mylong .exists()) {
                          mylong.delete();
                          //mylong.createNewFile();
                      } else {
                            //mylong.createNewFile();
                              myemigrant = new File (mydir.getParent()+"\\_emigrant.dat");
                              if (myemigrant.exists()) {
                                   myemigrant.delete();
                                  // myemigrant.canWrite();
                                } else {
                                     //  myemigrant.canWrite();
                   mytravel= new File (mydir.getParent().toString()+"\\_traveller.dat");
                    if (mytravel.exists()) {
                        mytravel.delete();
                       // mytravel.createNewFile();
                      } else {
                           //mytravel.createNewFile();
                    myinstitution = new File (mydir.getParent().toString()+"\\_institution.dat");
                    if (myinstitution.exists()) {
                          myinstitution.delete() ;
                         // myinstitution.createNewFile();
                      } else {
                           //myinstitution.createNewFile();
                    myvagrant = new File (mydir.getParent().toString()+"\\_vagrant.dat");
                    if (myvagrant .exists()) {
                         myvagrant.delete();
                        // myvagrant.createNewFile();
                      } else {
                           //myvagrant.createNewFile();
         //}//initial
              for( int index2 =0;index2<myList.size();index2++)//loop the second one for individual files
                   File file= (File)myList.get(index2);
                   if (file.getParent().contains("00"))//leave node
                        parentPath =file.getParent().substring(0, file.getParent().length()-4);
                   else
                        parentPath =file.getParent().substring(0, file.getParent().length()-3);
                   if (parentPath.toString().compareTo(directory.getParent())==0&file.getName().contains("cover"))
                        try {
                             in = new BufferedReader(new FileReader(file));
                             out = new BufferedWriter( new  FileWriter(mycover));
                        ************     while ((read =in.readLine())!=null)
                             System.out.println("testing");//test whether i ever get in this section !!!
                             out.write(read);               
                             out.close();
                             in.close();
                        catch(NullPointerException e)
                             System.out.println(e);
                        catch(IOException e)
                             System.out.println("There was a problem:" + e);
    }//class Directories

    kingspalace wrote:
    Dr Clap
    The problem i am having is that whereas i am very sure that there are contents in the files i am trying to read , this part of the code Print the Values of parentPath,directory.getParent() and file.getName() here .In the start of this if condition to get a idea what stuff is coming here.
    if (parentPath.toString().compareTo(directory.getParent())==0&file.getName().contains("cover"))
                   {Are you trying to compare parentPath and directory.getParent() as Strings ? How about using equals() ?
    Also are you aware that a single & and && are not one and the same ?
    & will check nevertheless even if the string comparison on the parentPath returns true or false.
    && will not check file.getName() part if the String comparison part fails.
                        try {
                             in = new BufferedReader(new FileReader(file));
                             out = new BufferedWriter( new FileWriter(mycover));
                        ************     while ((read =in.readLine())!=null)
                             System.out.println("testing");//test whether i ever get in this section !!!
                             out.write(read);               
                             out.close();
                             in.close();
                        catch(NullPointerException e)
                             System.out.println(e);
                        catch(IOException e)
                             System.out.println("There was a problem:" + e);
                             }How about adding a simple Exception catch block here ,in case you miss anything ?
    never gets executed executed (meaning ,according to the code, the files am reading have no content ). i am a bit new to files and directories in java . i am hence seeking advice on what i could be doing wrong .IN short,debugging your code will help you a lot.

  • File adapter  reading and writing large files

    Hi we are getting error when trying to process large files using file adapters. files of size 80 to 100 MB. we need to read the inbound files and write them to another folder in another server. the error we are getting is out of memory. gracias

    Hi,
    Use the asynchronous process or a checkpoint(); to see your instance before it time-out.
    --Khaleel                                                                                                                                                                                                                           

  • READING AND WRITING TXT FILE, GUI COMPONENTS.

    HI GUYS I AM JUST NEW TO JAVA AND I AM TRYING TO LEARN SOME MORE IN JAVA. SO I NEED HELP FROM YOU GREAT GUYS WHO KNOWS MORE & MORE THING THAN ME. I CODE A GUI FOR THIS PROGRAM. THE CODE IS BELOW.
    This program has to read a txt file to create Food objects which will consist of a food name, a serving size, and a number of calories. A text file is read which contains the calories contained in specific food items. From this data, an array of Food objects will be created and used to populate a combo box for user selection. The Food objects will also be used in calculating the balance calories for a given user on a given day.
    User input will be used to create User objects which will be user name, age, gender, height, weight, and Food Diary objects (composition). The Food Diary objects will consist of Date (composition), Food object (composition), number of servings, and a balance. Food Diary objects will consist of the activity on any given day (see text area in sample output screen below). All User objects are saved to a file as objects and can be retrieved on subsequent runs of the program.
    The program will calculate the number of calories the user is allowed per day to maintain the user�s current weight (see below for formula to use for this).
    BMRMen = 66 + (13.7 * weightPounds/2.2) + (5 * heightInches*2.54) - (6.8 * age)
    BMRWomen = 655 + (9.6 * weightPounds/2.2) + (1.8 * heightInches*2.54) - (4.7 * age)
    GUI CODE
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class FoodDiaryGUI extends JFrame implements ActionListener {
         JLabel               lblName, lblAge, lblWeight,lblHeight,lblFemale,lblMale,lblFood;
         JTextField          txtName, txtAge, txtWeight,txtHeight;
         JButton               btnSave, btnNewUser;
         JTextArea           outputArea;
         JComboBox          cbFood;
         int currentIndex=0, lastIndex=4;
         public FoodDiaryGUI()
              super ("Food Diary Calculator");
              lblName=               new JLabel("Name: ");
              lblAge=                    new JLabel("Age: ");
              lblWeight=               new JLabel("Weight(lbs): ");
              lblHeight=               new JLabel("Height(inches): ");
              lblFemale=               new JLabel("Female: ");
              lblMale=               new JLabel("Male: ");
              lblFood=               new JLabel("Choose a Food: ");
              txtName=               new JTextField(15);
              txtAge=                    new JTextField(3);
              txtWeight=               new JTextField(6);
              txtHeight=               new JTextField(6);
              outputArea=               new JTextArea(9,20);     
              cbFood=                    new JComboBox();
              cbFood.setPreferredSize(new Dimension(100, 20));
              Container c = getContentPane();
              JPanel northPanel = new JPanel();
              northPanel.setLayout(new FlowLayout());
              btnSave=               new JButton("SAVE");
              northPanel.add(btnSave);
              btnNewUser=               new JButton("NEW USER");
              northPanel.add(btnNewUser);
              btnSave.addActionListener(this);
              btnNewUser.addActionListener(this);
              JPanel centerPanel = new JPanel();
              centerPanel.setLayout(new FlowLayout());
              centerPanel.add(lblName);
              centerPanel.add(txtName);
              centerPanel.add(lblAge);
              centerPanel.add(txtAge);
              centerPanel.add(lblWeight);
              centerPanel.add(txtWeight);
              centerPanel.add(lblHeight);
              centerPanel.add(txtHeight);
              centerPanel.setLayout(new FlowLayout());
              JRadioButton rbMale = new JRadioButton(maleString);
         birdButton.setMnemonic(KeyEvent.VK_M);
         birdButton.setActionCommand(maleString);
         birdButton.setSelected(true);
         JRadioButton rbFemale = new JRadioButton(femaleString);
         catButton.setMnemonic(KeyEvent.VK_F);
         catButton.setActionCommand(femaleString);
         //Group the radio buttons.
         ButtonGroup group = new ButtonGroup();
         group.add(rbMale);
         group.add(rbFemale);
         //Register a listener for the radio buttons.
         rbMale.addActionListener(this);
         rbFemale.addActionListener(this);
         public void actionPerformed(ActionEvent rb) {
         picture.setIcon(new ImageIcon("images/"
         + rb.getActionCommand()
         + ".gif"));
              radioGroup.add(rbMale);
              radioGroup.add(rbFemale);
              centerPanel.add(rbMale);
              centerPanel.add(rbFemale);
              centerPanel.add(lblFood);
              centerPanel.add(cbFood);
              JPanel southPanel = new JPanel();
              southPanel.setLayout(new FlowLayout());
              southPanel.add (outputArea);
              c.add(northPanel,BorderLayout.NORTH);
              c.add(centerPanel,BorderLayout.CENTER);
              c.add(southPanel,BorderLayout.SOUTH);
              setSize(650,300);
              setVisible(true);
              //add listener to button components.
              public void actionPreformed(ActionEvent e)
                   if (e.getSource()==btnSave)
                        currentIndex++;
                        currentIndex--;
              public static void main (String[] args)
                   FoodDiaryGUI application = new FoodDiaryGUI();
                   application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              public void actionPerformed(ActionEvent arg0) {
                   // TODO Auto-generated method stub
    THE .txt file is as:
    1000 ISLAND, SALAD DRSNG,LOCAL*1 TBSP*25
    1000 ISLAND, SALAD DRSNG,REGLR*1 TBSP*60
    100% NATURAL CEREAL *1 OZ*135
    40% BRAN FLAKES, KELLOGG'S*1 OZ*90
    40% BRAN FLAKES, POST*1 OZ*90
    ALFALFA SEEDS, SPROUTED, RAW*1 CUP*10
    ALL-BRAN CEREAL*1 OZ*70
    ALMONDS, WHOLE*1 OZ*165
    ANGELFOOD CAKE, FROM MIX*1 PIECE*125
    APPLE JUICE, CANNED*1 CUP*115
    i hope this forum site has to many java professionals and this problem is nothing for them. for me it is great.

    Stick to using a single userid and a single posting of a question:
    http://forum.java.sun.com/thread.jspa?threadID=731264&tstart=0

  • Reading and Writing large Excel file using JExcel API

    hi,
    I am using JExcelAPI for reading and writing excel file. My problem is when I read file with 10000 records and 95 columns (file size about 14MB), I got out of memory error and application is crashed. Can anyone tell me is there any way that I can read large file using JExcelAPI throug streams or in any other way. Jakarta POI is also showing this behaviour.
    Thanks and advance

    Sorry when out of memory error is occurred no stack trace is printed as application is crashed. But I will quote some lines taken from JProfiler where this problem is occurred:
              reader = new FileInputStream(new File(filePath));
              workbook = Workbook.getWorkbook(reader);
              *sheeet = workbook.getSheet(0);* // here out of memory error is occured
               JProfiler tree:
    jxl.Workbook.getWorkBook
          jxl.read.biff.File 
                 jxl.read.biff.CompoundFile.getStream
                       jxl.read.biff.CompoundFile.getBigBlockStream Thanks

  • Very slow painting while reading and writing doubles into file

    for 15MB length file i = 7662080
    for 50MB length file i = 12414368
    Part of Code for writing into file follows like this:
    try{
    fos = new FileOutputStream("Angel.txt");
    File f = new File("Angel.txt");
         if(f.length() >=4)
         f.delete();
    fos = new FileOutputStream("Angel.txt");     
    dos = new DataOutputStream(new BufferedOutputStream(fos,1000000));
    int x=0;
    double y_last, y_new;
    for(int j=0 ;j<i ;j++)
    if(some condition)
    y_new = ....;
    try{
    //previously in vectors
    y_last = y_new;
    vect.add(new Line2D.Double(x, y_last, x, y_new)_;
    dos.writeDouble(y_new);
         }catch(Exception e){System.out.println(e);}
    dos.close();
    fos.close();
    x++;
    }catch(Exception excp){System.out.println(excp);}
    part of code for reading from file follows like this:
    public void paint(Graphics g)
    try{
         double y1, y2 =0;               
         Line2D.Double doub;
         raf = new RandomAccessFile("Angel.txt","r");
         dis = new DataInputStream(new BufferedInputStream(new FileInputStream(raf.getFD(),1000000)));
         raf.seek((rect.x*8));
         for (int i = 0/any value; (i < value as per choice); i++)
              g2.setStroke(new BasicStroke(0)); //2
              y1 = y2;
         y2 =dis.readDouble();
              doub=new Line2D.Double(i,y1,i,y2);
              g2.draw(doub);
    dis.close();
         raf.close();
    }catch(Exception excp){System.out.println(excp);}
    I tried using Object Streams but NotSerializable Exception is thrown as Line2D.Double objects
    are not serialized.
    Any idea to make reading and writing into file specially from MB files faster is appreciated.

    Why are you reading in the file in the paint method ?
    Create your data once before painting.
    I think you should explain what is your goal and what behavior you want.
    Denis

  • Rreading and writing this file's metadata (xmp) has been disabled. Renders unplayable/corrupted files

    Hi everyone,
    I've been using Premiere Pro CC for a while now, as I have a YouTube channel, and I've rendered, exported and edited around a dozen different videos, and have had no issues until now. I haven't done anything to my settings, but randomly, I am now unable to export any videos. I've tried exporting multiple times, using different formats, and I still get the same error:
         File importer detected an inconsistency in the file structure of [FILE NAME]. Reading and writing this file’s metadata (XMP) has been disabled.
    I've looked around, and I've seen just about no help in fixing the issue, so I was hoping that someone could help me out.
    Some of my computer details are:
    Premiere Pro CC
    Toshiba Z10T
    Windows 8.1
    Hopefully that's enough to go by
    Thanks guys

    After moving LR3.5 and catalogs to a new computer running Windows 7 and LR from an XP system, I suddenly had 6400 files with exclamation points--failure to synch metadata or similar warnings on every file.  If I thought I had one without the error, if I clicked on it--there error showed up.    It was very frustrating and I was wondering if I was going to have to keep my old computer forever.
    After I searched for a couple of hours and found that there have been several discussions concerning failures to sync xmp sidecar files and failures to write metadata on this forum and others.  Some of the postings had angry rants against Adobe.  On my system, it was not Adobe that should be blamed, it was Microsoft:
    On one of the Adobe threads, I noticed a post that the person had multiple external drives and the problem did not show itself on one drive.  The person said that changing the permissions on the other hard drives solved the problem.   I tried this and it worked for me.  I did not have this problem with this same drive on my XP system.  I will try to find that other forum and thank the person who gave me the solution.

  • How to read and write to file on server

    can any body tell how to read or write to a file on server, like where do i keep the file and what does the path look like......on server
    stand alone i am reading and writing into file but when it comes to server i am confused how it works...i mean the path
    thank you

    The Path needs to be absolute:
    For example in Unix it would look like:
    /usr/paz/Test.txtIn Windows it would look like:
    C:/Paz/Test.txtHope this helps.
    Thanks and regards,
    Pazhanikanthan. P

  • Problem on reading and writing from from a *.txt file

    I get Problem on reading and writing from from a *.txt file. The following is the read() method...
    The software said the DataInputStream is depreciated. Can anyone help me please?
    public void read()
        File file = new File("C://Documents and Settings//Charles//My Documents//Brunel//EE2065//Assignment and Lab//Assignment 4 and Lab 4//data.txt");
        FileInputStream in = null;
        String str = "";
        try
          in = new BufferedReader(file);
          //in = new FileInputStream(file);
          for(;;)
            str = new BufferedReader(in).readLine();
            //str = new DataInputStream(in).readLine();
            if(str == null)
              break;
            System.out.print(str);
        in.close();
        catch(IOException e)
            System.err.println("execution error: " +e);
      }

    Thank you for your reply. I have made some change. However, there is an incompetable type found error.
    in = new BufferedReader(new InputStreamReader(in));The following are all of the code.
    public void read()
        File file = new File("C://Documents and Settings//Charles//My Documents//Brunel//EE2065//Assignment and Lab//Assignment 4 and Lab 4//data.txt");
        FileInputStream in = null;
        //BufferedReader in = null;
        String str = "";
        try
          in = new BufferedReader(new InputStreamReader(in));
          //in = new FileInputStream(file);
          for(;;)
            BufferedReader Bstr = new BufferedReader(new InputStreamReader(in));
            //str = new BufferedReader(in).readLine();
            //str = new DataInputStream(in).readLine();
            if(str == null)
              break;
            System.out.print(str);
        in.close();
        catch(IOException e)
            System.err.println("execution error: " +e);

  • IPhone4 how through the USB mobile phone file reading and writing?

    iPhone4 how through the USB mobile phone file reading and writing?

    No idea what you are asking.
    Please explain

  • Quickest method for reading and writing files

    Hi
    I need help regarding file operations.(Reading and Writing). Currently I am using BufferedReader and BufferedWriter to read and write files. But the files (XML) are very huge files(from 30 -50 mb). This is slowing the application to a great extent. Is there any other approach to perform the above mentioned operations on XML files in a fast manner.
    Thank You
    Mansoor.

    Hi
    Can u let me know how to use the java.nio pavkage for primitve data types(int,float..., boolean). I have tried it but found no success.
    Thank You
    Mansoor

  • How to read and write a file in unicode?

    Hello!
    I have a problem with reading and writing files which are saved in unicode. with my current code I get strange boxes in my text
    Do you need a special Reader/Writer for this?
    Please, help me if you have any ideas.
    cheers
    import java.io.*;
    import java.util.*;
    public class StreamConverter {
       static void writeOutput(String str) {
           try {
               FileOutputStream fos = new FileOutputStream("test_uni.txt");
               Writer out = new OutputStreamWriter(fos, "UTF8");
               out.write(str);
               out.close();
           } catch (IOException e) {
               e.printStackTrace();
       static String readInput() {
          StringBuffer buffer = new StringBuffer();
          try {
              FileInputStream fis = new FileInputStream("file_uni.txt");
              InputStreamReader isr = new InputStreamReader(fis, "UTF8");
              Reader in = new BufferedReader(isr);
              int ch;
              while ((ch = in.read()) > -1) {
                 buffer.append((char)ch);
              in.close();
              return buffer.toString();
          } catch (IOException e) {
              e.printStackTrace();
              return null;
       public static void main(String[] args) {
            String inputString = readInput();
            writeOutput(inputString);     
    }

    Are you saying there's only the three boxes at the beginning, and the rest of the text is okay? That sounds like a Byte Order Mark (BOM). The BOM is optional for UTF-8, but Java's I/O classes act like it's forbidden. They should check for it when reading so they can skip over it, but (for now, at least) we have to do that ourselves.
    All you have to do is read the first three bytes from the InputStream and compare them to the BOM. If they match, you start reading the text from that position; otherwise you reset the InputStream and start reading from the beginning.
    http://en.wikipedia.org/wiki/Byte_Order_Mark

  • File Read and Write using File Adapter in Bpel

    In Bpel Process i am using File Adapter ( Schema is Opaque) for read and write the file contents. i am able do successful deployment and read, write function in first time deployment, after that again i tired to run the application, its not going to write the content of file, its only writing the file with out data's or content in that file.
    Please help me...
    Saravanan

    Hi Eric
    In my domain.log file having the following details. In this file im unable to find out what the exact problem. Please look at this and help me.
    <2008-01-22 18:25:42,024> <INFO> <default.collaxa.cube.compiler> validating "C:\product\10.1.3.1\OracleAS_1\bpel\domains\default\tmp\.bpel_BPELProcess2_1.1_298e83988d77b6640c33dfeec11ed31b.tmp\BPELProcess2.bpel" ...
    <2008-01-22 18:25:49,850> <INFO> <default.collaxa.cube.engine.deployment> <CubeProcessFactory::generateProcessClass>
    Process "BPELProcess2" (revision "1.1") successfully compiled.
    <2008-01-22 18:25:49,914> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> Loading JCAActivationAgent for {portType=Read_ptt}
    <2008-01-22 18:25:49,914> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> JCAActivationAgent::load - Locating Adapter Framework instance: OraBPEL
    <2008-01-22 18:25:49,930> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> JCAActivationAgent::load - Done loading JCAActivationAgent for processId='bpel://localhost/default/BPELProcess2~1.1/
    <2008-01-22 18:25:49,930> <INFO> <default.collaxa.cube.engine.deployment> Process "BPELProcess2" (revision "1.1") successfully loaded.
    <2008-01-22 18:26:02,698> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> JCAActivationAgent::uninit Shutting down the JCA activation agent, processId='bpel://localhost/default/BPELProcess2~1.0/', activation properties={portType=Read_ptt}
    <2008-01-22 18:26:02,698> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> Adapter Framework instance: OraBPEL - performing endpointDeactivation for portType=Read_ptt, operation=Read
    <2008-01-22 18:26:02,698> <INFO> <default.collaxa.cube.ws> <File Adapter::Outbound> Endpoint De-activation called in adapter for endpoint : D:\MAXIMUS_Project_Softwares\jdevstudiobase10132\jdev\mywork\MyLabs\BPELProcess2\in
    <2008-01-22 18:26:02,698> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> JCAActivationAgent::init - Initializing the JCA activation agent, processId='bpel://localhost/default/BPELProcess2~1.1/
    <2008-01-22 18:26:02,698> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> JCAActivationAgent::initiateInboundJcaEndpoint - Creating and initializing inbound JCA endpoint for:
    process='bpel://localhost/default/BPELProcess2~1.1/'
    domain='default'
    WSDL location='rd.wsdl'
    portType='Read_ptt'
    operation='Read'
    activation properties={portType=Read_ptt}
    <2008-01-22 18:26:02,698> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> Adapter Framework instance: OraBPEL - endpointActivation for portType=Read_ptt, operation=Read
    <2008-01-22 18:26:02,730> <INFO> <default.collaxa.cube.activation> <File Adapter::Inbound> Endpoint Activation called in File Adapter for endpoint: D:\MAXIMUS_Project_Softwares\jdevstudiobase10132\jdev\mywork\MyLabs\BPELProcess2\in
    <2008-01-22 18:26:02,730> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> Adapter Framework instance: OraBPEL - successfully completed endpointActivation for portType=Read_ptt, operation=Read
    <2008-01-22 18:26:02,890> <WARN> <default.collaxa.cube.activation> <File Adapter::Inbound> PollWork::run exiting, Worker thread will die
    <2008-01-22 18:26:04,171> <INFO> <default.collaxa.cube.ws> <File Adapter::Outbound> Managed Connection Created
    <2008-01-22 18:26:04,171> <INFO> <default.collaxa.cube.ws> <File Adapter::Outbound> Connection Created
    <2008-01-22 18:26:04,171> <INFO> <default.collaxa.cube.ws> <File Adapter::Outbound> FileInteraction Created

  • OIP-04907: LOB operation failed. Error reading or writing to file'

    I wrote a VB program who read and write blob
    I received this error
    OIP-04907: LOB operation failed. Error reading or writing to file'
    do you have an idea why
    or
    where Can I find some info about this error (OIP)
    thanks

    Hello SteveMRG,
    What version of LabVIEW and NI DAQmx are you using? Does this error occur when the program is run from the development PC from the project? Can you create a debuggable executable and activate Highlight execution when the error occurs as to verify which state the program is in?
    Wear
    National Instruments
    Product Support Engineer

Maybe you are looking for