Results 1 to 4 of 4
  1. #1
    Andrea is offline Member
    Join Date
    Aug 2013
    Posts
    3
    Rep Power
    0

    Default FileOutputStream

    Hello World =p

    My program should read itself to store it's content in byte array b[] and copy the content in a textfile, using FileInputStream and FileOutputStream. This is homework from my prof :)
    Can anybody please help make it work? THX :)

    [JAVA]
    package inpOutBeisp;
    import java.io.*;
    public class FileCopy{
    public static void main(String[] args){
    File dir = new File(".\\inpOutBeisp");
    File fil = new File(dir, "FileCopy.java");
    File copy = new File("FileCopy.txt");
    int datLaenge = (int)fil.length();
    byte b[] = new byte[datLaenge];
    FileInputStream fis;
    FileOutputStream fos;
    try{
    fis = new FileInputStream(fil);
    fos = new FileOutputStream(copy);
    int l = fis.read(b, 0, datLaenge); //Why int l? What does this?
    fis.close();
    fos.write(b,0,datLaenge);
    fos.close();
    }
    catch(FileNotFoundException ffe){
    System.out.println("File not found");
    }
    catch(Exception e){}
    }
    }
    [/JAVA]

    Attatchment ist the exception, it throws.
    Attached Thumbnails Attached Thumbnails FileOutputStream-filecopy.bmp  

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: FileOutputStream

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Andrea is offline Member
    Join Date
    Aug 2013
    Posts
    3
    Rep Power
    0

    Default Re: FileOutputStream

    Many thanks, Darryl! I'm trying learning Java Programming, but I don't get it that fast like you experts. Because of that I'm asking for help =)

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: FileOutputStream

    Member Andrea has been banned for 1 month for violation of paragraph 5 of the Forum Rules. Two posts by the member in another thread have been removed from public view.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Clarification of FileOutputStream
    By rogi85 in forum New To Java
    Replies: 4
    Last Post: 08-03-2011, 12:02 PM
  2. FileOutputStream to GIF
    By dewitrydan in forum New To Java
    Replies: 12
    Last Post: 10-11-2010, 07:12 AM
  3. closing FileOutputStream?
    By mgrootsch in forum New To Java
    Replies: 1
    Last Post: 05-17-2010, 05:36 PM
  4. FileOutputStream > int > FileInputStream
    By dudejonne in forum New To Java
    Replies: 11
    Last Post: 11-11-2009, 04:03 PM
  5. FileOutputStream question...
    By SCS17 in forum New To Java
    Replies: 2
    Last Post: 07-07-2008, 05:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •