FileInputStream

I have a zip file in directroy A.i'm unzipping the the zip file,creating a new directory in another folder and writing the file to the new folder.But its threowing me a file not found exception.Its creating problem in the FileInputStream.Suggestions plz...

ZipFile zFile = new ZipFile(tempFile);
Enumeration zipEntries = zFile.entries();
String logFile = null;
String fExtn=null;
String gbsFile=null;
while(zipEntries.hasMoreElements())
ZipEntry zEntry = (ZipEntry)zipEntries.nextElement();          
String fName = zEntry.getName();
fExtn = fName.substring(fName.length()-3);
fName=fName.substring(fName.indexOf("/")+1);
File f;
File fDir = new File(TMPHome+"\\BRCFiles");
fDir.mkdirs();
f=new File(fDir,fName);
FileInputStream fis=new FileInputStream(f);
BufferedInputStream inr= null;
FileOutputStream fout=new FileOutputStream(f.getPath());
BufferedOutputStream out=new BufferedOutputStream(fout);
byte [] fileData = null;
int readCount=0;
try{
inr = new BufferedInputStream(fis);
while ((readCount = inr.read()) > -1)
out.write(readCount);
out.flush();
fis.close();
fout.close();
inr.close();
out.close();
catch (FileNotFoundException e)
{e.printStackTrace();
catch (IOException e)
{e.printStackTrace();
}//end of while

Similar Messages

  • File and FileInputStream problem

    Hi all
    I have downloaded from developpez.com a sample code to zip files. I modified it a bit to suit with my needs, and when I launched it, there was an exception. So I commented all the lines except for the first executable one; and when it succeeds then I uncomment the next executable line; and so on. When I arrived at the FileInputStream line , the exception raised. When I looked at the code, it seemed normal. So I want help how to solve it. Here is the code with the last executable line uncommented, and the exception stack :
    // Copyright (c) 2001
    package pack_zip;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import oracle.jdeveloper.layout.*;
    import java.io.*;
    import java.util.*;
    import java.util.zip.*;
    import java.text.*;
    * A Swing-based top level window class.
    * <P>
    * @author a
    public class fzip extends JFrame implements ActionListener{
    JPanel jPanel1 = new JPanel();
    XYLayout xYLayout1 = new XYLayout();
    JTextField szdir = new JTextField();
    JButton btn = new JButton();
    JButton bzip = new JButton();
         * Taille générique du tampon en lecture et écriture
    static final int BUFFER = 2048;
    * Constructs a new instance.
    public fzip() {
    super("Test zip");
    try {
    jbInit();
    catch (Exception e) {
    e.printStackTrace();
    * Initializes the state of this instance.
    private void jbInit() throws Exception {
    this.getContentPane().setLayout(xYLayout1);
         this.setSize(new Dimension(400, 300));
    btn.setText("btn");
    btn.setActionCommand("browse");
    btn.setLabel("Browse ...");
    btn.setFont(new Font("Dialog", 0, 14));
    bzip.setText("bzip");
    bzip.setActionCommand("zipper");
    bzip.setLabel("Zipper");
    bzip.setFont(new Font("Dialog", 0, 14));
    btn.addActionListener(this);
    bzip.addActionListener(this);
    bzip.setEnabled(false);
         this.getContentPane().add(jPanel1, new XYConstraints(0, 0, -1, -1));
    this.getContentPane().add(szdir, new XYConstraints(23, 28, 252, 35));
    this.getContentPane().add(btn, new XYConstraints(279, 28, 103, 38));
    this.getContentPane().add(bzip, new XYConstraints(128, 71, 103, 38));
    public void actionPerformed(ActionEvent e)
    if(e.getActionCommand() == "browse")
    FileDialog fd = new FileDialog(this);
    fd.setVisible(true);
    szdir.setText(fd.getDirectory());
    bzip.setEnabled(true);
    else
              * Compression
         try {
              // création d'un flux d'écriture sur fichier
         FileOutputStream dest = new FileOutputStream("Test_archive.zip");
              // calcul du checksum : Adler32 (plus rapide) ou CRC32
         CheckedOutputStream checksum = new CheckedOutputStream(dest, new Adler32());
              // création d'un buffer d'écriture
         BufferedOutputStream buff = new BufferedOutputStream(checksum);
              // création d'un flux d'écriture Zip
         ZipOutputStream out = new ZipOutputStream(buff);
         // spécification de la méthode de compression
         out.setMethod(ZipOutputStream.DEFLATED);
              // spécifier la qualité de la compression 0..9
         out.setLevel(Deflater.BEST_COMPRESSION);
         // buffer temporaire des données à écriture dans le flux de sortie
         byte data[] = new byte[BUFFER];
              // extraction de la liste des fichiers du répertoire courant
         File f = new File(szdir.getText());
         String files[] = f.list();
              // pour chacun des fichiers de la liste
         for (int i=0; i<files.length; i++) {
                   // en afficher le nom
              System.out.println("Adding: "+files);
    // création d'un flux de lecture
    FileInputStream fi = new FileInputStream(files[i]);
    /* // création d'un tampon de lecture sur ce flux
    BufferedInputStream buffi = new BufferedInputStream(fi, BUFFER);
    // création d'en entrée Zip pour ce fichier
    ZipEntry entry = new ZipEntry(files[i]);
    // ajout de cette entrée dans le flux d'écriture de l'archive Zip
    out.putNextEntry(entry);
    // écriture du fichier par paquet de BUFFER octets
    // dans le flux d'écriture
    int count;
    while((count = buffi.read(data, 0, BUFFER)) != -1) {
              out.write(data, 0, count);
                   // Close the current entry
    out.closeEntry();
    // fermeture du flux de lecture
              buffi.close();*/
    /*     // fermeture du flux d'écriture
         out.close();
         buff.close();
         checksum.close();
         dest.close();
         System.out.println("checksum: " + checksum.getChecksum().getValue());*/
         // traitement de toute exception
    catch(Exception ex) {
              ex.printStackTrace();
    And here is the error stack :
    "D:\jdev32\java1.2\jre\bin\javaw.exe" -mx50m -classpath "D:\jdev32\myclasses;D:\jdev32\lib\jdev-rt.zip;D:\jdev32\jdbc\lib\oracle8.1.7\classes12.zip;D:\jdev32\lib\connectionmanager.zip;D:\jdev32\lib\jbcl2.0.zip;D:\jdev32\lib\jgl3.1.0.jar;D:\jdev32\java1.2\jre\lib\rt.jar" pack_zip.czip
    Adding: accueil188.cfm
    java.io.FileNotFoundException: accueil188.cfm (Le fichier spécifié est introuvable.
         void java.io.FileInputStream.open(java.lang.String)
         void java.io.FileInputStream.<init>(java.lang.String)
         void pack_zip.fzip.actionPerformed(java.awt.event.ActionEvent)
         void javax.swing.AbstractButton.fireActionPerformed(java.awt.event.ActionEvent)
         void javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(java.awt.event.ActionEvent)
         void javax.swing.DefaultButtonModel.fireActionPerformed(java.awt.event.ActionEvent)
         void javax.swing.DefaultButtonModel.setPressed(boolean)
         void javax.swing.plaf.basic.BasicButtonListener.mouseReleased(java.awt.event.MouseEvent)
         void java.awt.Component.processMouseEvent(java.awt.event.MouseEvent)
         void java.awt.Component.processEvent(java.awt.AWTEvent)
         void java.awt.Container.processEvent(java.awt.AWTEvent)
         void java.awt.Component.dispatchEventImpl(java.awt.AWTEvent)
         void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
         void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
         void java.awt.LightweightDispatcher.retargetMouseEvent(java.awt.Component, int, java.awt.event.MouseEvent)
         boolean java.awt.LightweightDispatcher.processMouseEvent(java.awt.event.MouseEvent)
         boolean java.awt.LightweightDispatcher.dispatchEvent(java.awt.AWTEvent)
         void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
         void java.awt.Window.dispatchEventImpl(java.awt.AWTEvent)
         void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
         void java.awt.EventQueue.dispatchEvent(java.awt.AWTEvent)
         boolean java.awt.EventDispatchThread.pumpOneEvent()
         void java.awt.EventDispatchThread.pumpEvents(java.awt.Conditional)
         void java.awt.EventDispatchThread.run()
    Thank you very much

    One easy way to send a file through RMI is to read all bytes of a file to a byte array and send this array as a parameter of a remote method. But of course you may have problems with memory when you send large files. The receive is simillary.
    Other way is to split the file and getting slices of the file, sending slices and re-assemble at destination. This assume that the file isn't changed through the full transfering is concluded.
    I hope these could help you.

  • How can I convert an InputStream to a FileInputStream ???

    How can I convert an InputStream to a FileInputStream ???

    Thanks for you reply, however, I am still stuck.
    I am trying to convert my application (which runs smoothly) to a signed applet. The following is the original (application) code:
    private void loadConfig() {
    String fileName = "resources/groupconfig";
    File name = new File(fileName);
    if(name.isFile()) {
    try {
         ObjectInputStream in = new ObjectInputStream(new FileInputStream(fileName));
         pAndGConfig = (PAGroupsConfig)in.readObject();
         in.close();
         return;
    } catch(ClassNotFoundException e) {
         System.err.println("++ERROR: "+e);
    } catch(IOException e) {
         System.err.println("++ERROR: "+e);
    System.out.println("Can't find file: " + fileName);
    Because all code and resources now reside in a Jar file (for the signed applet), I must use the following line to access the resources:
    InputStream is = this.getClass().getResourceAsStream(fileName);
    I then need to convert the 'InputStream' to 'ObjectInputStream' or 'FileInputStream' so that I can work with it.
    I would be very grateful if you could help shed some light on the matter - Cobram

  • Cant pass file from a dir to fileinputstream()

    hi !
    i am stuck here ..please help.
    I have an application that creates a dir called temp in home directory . and and a file which is named in following format. for example
    080718002220.txt
    i.e. systemdate.ext type . Since this files are created in real time and has no specific file name .How would i pass it to fileinputstream() .
    Note : only one file will be there at a time but has no fixed file name as is mentioned in tutorials.
    Is there a way to pass either the naming pattern or file extention to do select the file .??

    A hint: you can peruse a directory for its contents.
    A sidenote: *.* denotes the working directory, which might be different from the home directory.

  • Opening/Closing a FileInputStream

    Hi all,
    We have a .properties file that should be checked from a servlet. The servlet will be hit by a load balancer every 5 seconds to see if the current node is active.
    The old programmer in the company had it like this:
    Properties propsFile = new Properties();
    propsFile.load(new FileInputStream("some path"));
    // check the propertyAs I understand, the above code leaves the file open all the time. Also is this a potential memory leak?
    I'm thinking about changing it to
    Properties propsFile = new Properties();
    FileInputStream fis = new FileInputStream("some path");
    propsFile.load(fis);
    // check the property
    fis.close();is this better? Furthermore my manager wants me to check the last modified date of the file and do not read it if it has not changed since the last read.
    Would this bring a performance improvement? Since the file is only a few bytes long isn't it the same to just read it in one go?
    Thanks

    dvm wrote:
    I'm thinking about changing it to
    fis.close();
    is this better? Deffinitely, the number of files you can have open is limited.
    Furthermore my manager wants me to check the last modified date of the file and do not read it if it has not changed since the last read.This may make your manager feel better.
    Would this bring a performance improvement? It will bring a small saving which may or may not make a difference to your application.
    Since the file is only a few bytes long isn't it the same to just read it in one go?If the file is less than 64 kB its size isn't important.
    It could save around 0.1 ms to avoid read the filing, but parsing the file could take longer.
    You should be able to write a quick program to read and close the file repeatedly (for about 10 seconds) to get an estimate of how long this takes on your system.

  • How to find a specific char in fileinputstream?

    Hi
    I've opened a fileinputstream for a text file.
    I need to read through it char by char to eof in order to find occurances of some ascii characters e.g. "," or "@" etc
          int eofii =0;
          try
            FR = new FileReader("UnusualTextFile.txt");
            while(eoFii != -1)
               eofii = FR.read();       
               if (eofii != -1)
                 bytesRead++;
                 out.println((char) eofii);  //this prints the whole text file, one char at a time...
                                  //      Say, I would like to find the number of comma's in the text file ,
                                  //          I tried several variations, none of which work...
                 if (((char) eofii).compareTo (",")) out.println("It is a comma!");
                 if (((char) eofii) == ",") out.println("It is a comma!");
            }

    Is it possible to compare the locale-independ, ascii value?
    This file has some weird characters not on my keyboard?

  • Can't read a file using FileInputStream(String path)

    Hi,
    Platform: Fedora Core 3
    IDE: MyEclipse 3.8.1
    Servlet Container: Tomcat 5
    Framework: Struts 1.1
    JDK: 1.5
    1) I'm trying to read a file (mw.properties) which resides in the package aaa.ccc.uuu.struts using FileInputStream("/aaa/ccc/uuu/struts/mw.properties");
    The class (named MyAction) trying to read this file is in the following package
    aaa.ccc.uuu.struts.actions.MyAction
    2) The alternatives that I've tried is:
    a) FileInputStream("aaa/ccc/uuu/struts/mw.properties");
    b) FileInputStream("aaa/ccc/uuu/struts/mw.properties");
    c) FileInputStream("/mw.properties");
    d) FileInputStream("mw.properties");
    (/javaweb is the context path)
    e) FileInputStream("/javaweb/WEB-INF/classes/aaa/ccc/uuu/struts/mw.properties");
    f) FileInputStream("/classes/ccc/uuu/struts/mw.properties");
    g) FileInputStream("classes/aaa/ccc/uuu/struts/mw.properties");
    h)FileInputStream("/usr/local/jakarata-tomcat-5/webapps/javaweb/aaa/ccc/uuu/struts/mw.properties");
    i) FileInputStream("/WEB-INF/classes/aaa/ccc/uuu/struts/mw.properties");
    ...and so forth.
    3) My Tomcat directory structure looks like the following:
    javaweb
    -->src
    ---->aaa
    ------>ccc
    --------->uuu
    ------------>struts/mw.properies
    --------------->actions/MyAction.java (trying to read the mw.properties file from within this file)
    -->web
    --->WEB-INF
    ----->classes
    --------->aaa
    ------------>ccc
    ---------------->uuu
    ------------------->struts/mw.properties
    ----------------------->actions
    --------------------------->MyAction.class (I've placed the mw.properties file here as well)
    ----->jsp
    ------>some more folders
    Note that the mw.properties file is in the source directory as well as the classes directory - I did this to trouble shoot. As far as i know the correct place to put the mw.properties file is in the classes folder (taking into consideration the package structure obviously)
    I'll appreciate any help I'm really stumped! (Not sure if this is the correct forum to post this query)
    Cheers

    Hi,
    My knowledge about web applications is very limited. I would try to create a new file from the app using just a name, and not a path. I would then look for the created file to see where the current path is. But I guess you could figure it out by reading the documentation.
    /Kaj

  • Get file path name for an given FileInputStream

    It sounds wired, but I do want to see if it is possible. Say we have a FileInputStream fis, which has been instantiated and valid. I would like to get the File associated with this FileInputStream. Is this possible and how?
    Thanks.

    It sounds wired, but I do want to see if it is
    possible. Say we have a FileInputStream fis, which
    has been instantiated and valid. I would like to get
    the File associated with this FileInputStream. Is
    this possible and how?
    Thanks.A FileInputStream may not be associated with a "disk file" at all. From javadocs, FileInputStream can be created from a [url http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileInputStream.html#FileInputStream(java.io.FileDescriptor)]FileDescriptor, which can represent [url http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileDescriptor.html#skip-navbar_top]an open file, an open socket, or another source or sink of bytes.

  • Cannot resolve symbol - class FileInputStream

    I am getting the above error when I compile this following method; I get it in the first line of code.
    Anyone know why?
    private String readAndProcessData(FileInputStream stream)
          InputStreamReader iStrReader = new InputStreamReader(stream);
          BufferedReader reader = new BufferedReader(iStrReader);
          try
             output.setText("");
             String data=reader.readLine();
             while (data!= null){
                  output.append(data + "\n");
                  data=reader.readLine();}
          catch(IOException e)
             messageBox("Error in file input:\n" + e.toString());
    [code/]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I am already doing this in another class which is linked to this one.
    I have three classes and java.io is imported in the Inteface, and this method is in the model class.

  • FileInputStream read problem

    Hi!
    I have a problem with reading a byte[] buffer from a file using the FileInputStream:
    ----- code example -----
    File = new FileInputStream(filename);
    data = new byte[File.available()];
    File.read(data);
    String test = new String(data);
    ----- end example -----
    So, when I print the bytes of the array "data", some chars are strange (negative numbers).
    When I convert the byte array into a string, some of the ASCII codes of the string's chars are wrong (like 65533).
    What can I do?

    It totally depends on what kind of data you're trying to read in choosing between a reader and an input stream. If you're reading binary data (like an image), use the input stream and read bytes. If you're trying to read character data, use a reader:BufferedReader reader = new BufferedReader (new FileReader ("test.txt"));
    String line;
    while ((line = reader.readLine ()) != null) {
        // process line
    }Kind regards,
      Levi

  • Re: directory and FileInputStream issues.

    hello,
    so i am having a problem with my code. the code will look though text files of images and perform some calculations. previously i copied the java code file to every directory where the calculations were to be performed. a long and tedious procedure. so, i altered the code such that the java file would remain in one place, and i would imput a pathway. i have done similarly with some other java files with success, but i am getting several errors, and no calculations. below is the code.
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    import java.text.*;
    import java.lang.Object;
    import java.text.DecimalFormat;
    public class BPF
         public static void main(String args[]) throws Exception
    ////////////////////following data pertains to voxel values ////////////////////
              //String vHeight = JOptionPane.showInputDialog("Enter voxel height");
              Double voxelHeight = .4102; //Double.parseDouble(vHeight);
              double voxelWidth = voxelHeight;
              //String vDepth = JOptionPane.showInputDialog("Enter voxel depth");
              double voxelDepth = 6.5; //Double.parseDouble(vDepth);
              double voxelCube = voxelHeight * voxelWidth * voxelDepth;
              double volumeTotal = 0;
              double BPFratio = 0;
              double normalizedBPF = 0;
              int voxel;
              double lowCutOff = 250.00;
              double highCutOff = 900.00;
              double bgColor = -1;
              int nonParenchymaVoxels = 0;
              double voxelArea = voxelWidth * voxelHeight;
              int tissuePerimeterCount = 0;
    //////////////////////////following code pertains to files//////////////////////
              //String fNumber = //JOptionPane.showInputDialog("Enter number of files");
              int numOfFiles = 19;//Integer.parseInt(fNumber);
              //String file =  //JOptionPane.showInputDialog("Enter name/number of first file");
              int fileName = 61;//Integer.parseInt(file);
              int count = 0;
              String fileNumber;
              String input;     // image.txt as string
              String deliminator = " \r\t\n.,:;?!/()[]{}|~\"*<>=+&^%$#@_";  // items i overlook when compiling input string 
              String filePath = JOptionPane.showInputDialog("Enter file execution path");
            String addendumOutPut;
             FileOutputStream outPut; // declare a file output object
            PrintStream p;
            try
                     outPut = new FileOutputStream(filePath + "Results.txt");// Creates a new file output stream connected to "BPF Results.txt"
                        p = new PrintStream(outPut);// Connect print stream to the output stream
            catch (Exception e)
                     System.err.println ("Error writing to file");
            for (int iterator = 1; iterator <= numOfFiles; iterator++)
                        System.out.println("\n" + "the count is " + iterator);     
                        fileNumber = String.valueOf(fileName);     // give String fileNumber the converted string value of fileName (the first file # in the list)
                        addendumOutPut = filePath + "addendumOutPut".concat(fileNumber); //add data to file each time loop runs
    /*line 86*/          System.out.println("the starting value is: " + fileName);  
                        FileReader inputImage = new FileReader(fileNumber + ".txt");  //used to open the file
                        BufferedReader binputImage = new BufferedReader(inputImage);  //reads lines of text in file
                        Vector voxelValueVector = new Vector();     // complete input file as vector
    //////////////////// placing text file numbers in vector ///////////////////////
                        while ((input = binputImage.readLine()) != null)
                                  StringTokenizer numbers = new StringTokenizer(input, deliminator);
                                  while (numbers.hasMoreTokens())
                                            count++;       //just to keep track of which film i am looking at
                                            String voxelValues = numbers.nextToken(); //reads #s 1by1, line by line
                                            voxel = Integer.valueOf(voxelValues).intValue();     //converts string to numerical (integer) value of pixel
                                            voxelValueVector.add(voxel);     // adds numerical value of pixel to vector
                        int voxelValueArray[] = new int[voxelValueVector.size()];     //creates array that is same size as vector
                        for (int i = 0; i < voxelValueVector.size(); i++)
                                 Integer voxelValueList = (Integer)(voxelValueVector.get(i));     //make vector into integers
                                 voxelValueArray[i] = voxelValueList.intValue();
                        for (int i = 0; i < voxelValueVector.size(); i++)
                                  if (voxelValueArray[i] > bgColor)
                                       tissuePerimeterCount++; //number of voxels within perimeter
                                       if (voxelValueArray[i] <= lowCutOff || voxelValueArray[i] >= highCutOff)
                                                 nonParenchymaVoxels++;     //non brain tissue
                        double volumeBrainSurfaceCountour = tissuePerimeterCount * voxelCube; //volume of brain within perimeter including csf etc...
                        double parenchymaTissue = tissuePerimeterCount - nonParenchymaVoxels;     //voxel count of parenchyma tissue
                        double volumeParenchyma = parenchymaTissue * voxelCube;      //volume of parenchyma tissue
                        double volumeNonBrain = nonParenchymaVoxels * voxelCube;      //volume of non-brain elements
                        double ratio = parenchymaTissue / tissuePerimeterCount;          //BPF ratio
                        volumeTotal = volumeParenchyma + volumeTotal; //summation of parenchyma tissue
                        BPFratio = BPFratio + (volumeParenchyma * ratio); //running summation of ratio * parenchyma tissue - used for normalized BPF
                        addendumOutPut = filePath + "BPF Results.txt";
                        try
                                 outPut  = new FileOutputStream(filePath + " Results.txt");// Create a new file output stream connected to "BPF Results.txt"
                                  p = new PrintStream(outPut);// Connect print stream to the output stream
                                  BufferedWriter addendumData = new BufferedWriter (new FileWriter(addendumOutPut, true));
                                  System.out.println("The total number of voxels for " + fileName + " is: " + voxelValueVector.size());
                                  System.out.println("The total number of voxels within tissue perimeter: " + tissuePerimeterCount);
                                  System.out.println("The total volume of the brain (including csf) is: " + volumeBrainSurfaceCountour);
                                  System.out.println("Volume of non-brain elements: " + volumeNonBrain);
                                  System.out.println("Volume of brain elements: " + volumeParenchyma);
                                  System.out.println("The BPF is: " + ratio);
                                  System.out.println("BPF running count " + BPFratio);
                                  addendumData.write("Stack " + fileName + "\n");
                                  addendumData.write("Total volume " + " \t" + volumeBrainSurfaceCountour + "\n");
                                  addendumData.write("Non-brain volume " + " \t" + volumeNonBrain + "\n");
                                  addendumData.write("Parenchyma volume " + " \t" + volumeParenchyma + "\n");
                                  addendumData.write("BPF " + " \t" + ratio + " \n" + "\n");
                                  if (iterator == numOfFiles)
                                            addendumData.write("boo");
                                            normalizedBPF =  BPFratio / volumeTotal;
                                            System.out.println("normalized BPF is " + normalizedBPF);
                                            addendumData.write("Running Paryenchyma volume" + "\t" + volumeTotal + "\n");
                                            addendumData.write("total BPF" + "\t" + BPFratio + "\n");
                                            addendumData.write("Normalized BPF" + " \t" + normalizedBPF + "\n");
                                   addendumData.close();
                                   //System.out.println("The running volume tally is " + volumeTotal);
                                  //System.out.println();
                                  //System.out.println(count);
                        catch (IOException e)
                                 System.out.println("IOException:");
                               e.printStackTrace();
                        fileName++;
                        tissuePerimeterCount = 0;
                        parenchymaTissue = 0;
                        volumeBrainSurfaceCountour = 0; //area of brain within perimeter including csf etc...
                        volumeParenchyma = 0;
                        ratio = 0;
                        nonParenchymaVoxels = 0;
    }it is quite a bit to read through. i can say that the results.txt file is created, but it contains no data. the line
                        System.out.println("the starting value is: " + fileName);   is there for me to find at what point where i think the code stops functioning properly. (line 86).
    the error messages are saying that
    1. the text file (61.txt) cannot be found.
    2. the remaining 4 errors pertain to FileInputStream
    any help is greatly appreciated.

    it has been a few days, and i completely forgot to post that i figured out the problem. when we last checked in, i was having problems with a code that would function when i copied the java file to a folder where it would be executed. as i needed to do this hundreds of times, it made more sense to input a pathway so i could have just one file. the problem...adding in the pathway produced a text file that contained no data. i posted my quagmire in the java forum and waited. it was met with a flurry of enthusiam that tended more towards sarcasm. i did eventually conquer the problem, so, here it is...
    outPut  = new FileOutputStream(filePath + " Results.txt");was changed to:
    outPut  = new FileOutputStream("Results.txt");...problem solved, and the program works like a swiss watch.

  • Fileinputstream problem in session bean

    Hi i m using fileInputStream in Seesion bean to read one file. but i want to give relative path of that file according to ear. but it give me fileNotFound Exception.. i cant give physical path of that file.. the file i m trying to read exists in the ear..
    can u help me out?
    Venky

    I have read some good number of XMLs and property files. Make use of Class.getResourceAsStream()method by passing the file name as argument. From the InputStream construct FileInputStream.

  • FileInputStream's read() outputs differently when not stored in a variable

    Here's my original code:
    import java.io.*;
    class ShowFile {
         public static void main(String[] args)
         throws IOException{
              FileInputStream fin = new FileInputStream(args[0]);
              int i;
              do {
                   i = fin.read();
                   if (i != -1) System.out.print((char) fin.read());
              }while (i != -1);
    }When i do a "java ShowFile test.txt", it outputs characters that's not the same as the ones in test.txt.
    But when I changed the code
    if (i != -1) System.out.print((char) fin.read()); to if (i != -1) System.out.print((char) i); everything outputs fine. Why is that?

    ajushi wrote:
    Thanks laginimaineb.You're welcome.
    ajushi wrote:
    So when I assign the resulting value from read(), is read() called? Is that the reason why I'm reading 2 chars per loop?Exactly, when you "assign the resulting value from read()" you actually call read, it performs what it needs to, and it returns some value, which you then use.
    laginimaineb.

  • FileInputStream problem

    I have a problem for inserting image to database from my client machine to server machine. In my webapplication I use the following implamentation using jsp:
    page: upload.jsp
    <form id="myform" name="myform" method="post" action="uploadprocess.jsp">
    Attach: <input type="file" name="attach"/>
    <input type="submit" name="BtnSend" value="Send" />
    </form>
    page: uploadprocess.jsp
    File anexo = new File(attach);
    FileInputStream fis = new FileInputStream(attach);
    [..] //here I have more codes that are ok...
    the problema is:
    when I'm using my webapplication in server machine (where java application server is running), it works perfect when the code line "FileInputStream fis = new FileInputStream(attach);" is read, because the application can recognize the path passed in var "attach". But, where I'm using in another client machine, where the webapplication isn't running, this recognize the file system of the server machine and not the client (local) machine....
    Could anybody help me to solve this problem?!

    I believe your problem is how you're trying to access the file... You should be accessing it via a data stream, not it's filename!
    Anyway, have a look at the following link, you should find it useful.
    http://commons.apache.org/fileupload/
    HTH.
    Edited by: munyul on Jun 3, 2008 1:37 AM

  • EntityResolver problem with InputStream other than FileInputStream

    Hi everybody,
    I have problems with resolving entities. I tried parsing xml-data with JAXP / Xerces 2.6 Sax and needed an EntityResolver for including xml-data, stored in an external-file:
    <!ENTITY test SYSTEM "test.xml">
    <a>
    &test;
    </a>It was working, as long as I put the xml above in a file and used a fileInputStream for creating the inputSource-object. Of course I set a SystemId with the path to test.xml. When I used a fileInputStream, the EntityResolver was called (I implemented it just for tracing reasons) and my data was processed correctly. As soon as I put the xml above e.g. in a ByteArrayInputStream, and used this for creating a InputSource-object, the my EntityResolver wasn't called and it didn't work. So why is this problem with EntityResolver and other Streams but FileInputStream?? Is it a bug? Did I miss something??
    Thanks for any help!!!

    I appologize for my mistake with my first post.
    While I was copying the code for this forum today, I recognized a typing error in my xml-string:
    String xmlString = "<?xml version=\"1.0\"?> <!DOCTYPE staticinc [ <!ENTITY test SYSTEM \"test.xml\">]><a>%test;</a>";I used a percent-sign instead of amp for the test-entity, and as stupid this is - this was of course the reason for my entity resolver not being called. I get a warning by xml-editors if I have this error in a file, but not during parse of a string.
    Somehow I got on the wrong track, because of the description I found in the other thread about entityResolver problems for "none-file-sources" and it seemed to fit.
    Again, sorry !! Thanks for your offer to help!!

Maybe you are looking for

  • Trouble copying data fies from DVD to hard Drive

    I just installed a second hard drive in my G5, and also 4 gigs of memory. Everything is working fine except my superdrive. I tried copying video files from a DVD to my hard drive and ran into problems. the files would begin cpying and then about half

  • Images of ipad for printing

    Hi, dont know if this is the right forum but i am looking for images of the ipad to put on to our works web site. Does anybody know where i could download some that are Royality free or safe to use on a commercial website? It is to show the ipad as a

  • Missed elements

    Why does acrobat X sometimes miss out elements when I print from a word 2010 document.  I have just printed a document for a client and there are whole text boxes missing from the pdf file.  Anyone else have this experience? How do I get it to print

  • How to get achieve this in JSP ?

    Hi friends, I am trying to do one scenario in jsp page. here are the steps. 1) when i click on submit button on home page (its already there) a new window should be opened. 2) while opening this new window , it will invoke one shell script and it res

  • Facing problem Using SYNC/ASYN in ID

    Hi all,   In BPM i am using SYNC/ASYNC bridge for that Outbound Interface and BPM Sync Interface has the same structure is it mapping necessary for that intercaces. In interface determination it is showing error in ID test configuration duplicate int