Results 1 to 2 of 2
  1. #1
    Java Tip's Avatar
    Java Tip is offline Moderator
    Join Date
    Nov 2007
    Posts
    1,694
    Blog Entries
    430
    Rep Power
    9

    Default Reading/Writing files through Applet

    Code below demonstrates how read and write a file using an applet.
    Java Code:
    	int arrlen = 10000;
    	byte[] infile = new byte[arrlen];
    	Frame parent = new Frame();
    	FileDialog fd = new FileDialog(parent, "Please choose a file:",
    	           FileDialog.LOAD);
    	fd.show();
    	String selectedItem = fd.getFile();
    	if (selectedItem == null) {
    		// no file selected
    	} else {
    		File ffile = new File( fd.getDirectory() + File.separator +
    		        fd.getFile());
    		// read the file
    		System.out.println("reading file " + fd.getDirectory() +
    		                         File.separator + fd.getFile() );
    		try {
    			FileInputStream fis = new FileInputStream(ffile); 
    			BufferedInputStream bis = new BufferedInputStream(fis);
    			DataInputStream dis = new DataInputStream(bis);
    			try {
    				int filelength = dis.read(infile);
    				String filestring = new String(infile, 0, filelength);
    				System.out.println("FILE CONTENT=" + filestring);
    			} catch(IOException iox) {
    				System.out.println("File read error...");
    				iox.printStackTrace();
    			}
    		} catch (FileNotFoundException fnf) {
    			System.out.println("File not found...");
    			fnf.printStackTrace();
    		}
    	}

  2. #2
    ravykiran is offline Member
    Join Date
    Mar 2009
    Posts
    1
    Rep Power
    0

    Default need code how to store pixels of an image in to file

    our project is on an application of data encryption standard to bit map and jpeg images i require a code for stories pixels on to a file it's very urgent plzz some body help me

Similar Threads

  1. Reading data from Micrsoft excel and writing to notepad
    By abhishek.jain in forum New To Java
    Replies: 4
    Last Post: 01-29-2009, 08:12 AM
  2. writing and reading unicode characters from a file
    By ranoosh in forum Advanced Java
    Replies: 4
    Last Post: 09-28-2008, 04:34 AM
  3. Applet - reading text files packed into JAR file
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-08-2008, 09:15 AM
  4. Reading/Writing a File using byte array
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-16-2008, 10:41 AM
  5. Help with File reading and writing
    By baltimore in forum New To Java
    Replies: 1
    Last Post: 07-31-2007, 06:47 PM

Posting Permissions

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