Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,797 members, 7,810,075 topics. Date: Friday, 26 April 2024 at 08:06 PM

Reading A Picture Into A File In Eclipse For Java Program - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Reading A Picture Into A File In Eclipse For Java Program (1330 Views)

Java Program To Solve Quadratic Equation-dealwap / Help!!no Build.gradle File In My Android Project (2) (3) (4)

(1) (Reply)

Reading A Picture Into A File In Eclipse For Java Program by logic101: 3:25pm On Oct 30, 2011
Hi i am trying to get a picture into a file in eclipse.
I have saved the picture into a folder called pic1.


public class Sandbox {

static String FILENAME ="pic1\\input.jpg";/
static int MTU = 1500;

File file;
FileInputStream fin;

file= new File(FILENAME);
buffer= new byte[(int) file.length()];
fin= new FileInputStream(file);
Re: Reading A Picture Into A File In Eclipse For Java Program by naijaswag1: 10:00pm On Oct 30, 2011
dont rily get what you are saying but hear this


Examples

URL url = InstructionalPackage.class.getResource("ojiakufinish.jpg"wink;

URL imgURLWrong = getClass().getResource("wrong.jpg"wink;

You have got to place the image in the path of your eclipse project,that somewhere in the src folder and read it in as a url object,and pass it to imageicon,you could place it on a label and display;this way it can also be available when you package your program as a jar file.

(1) (Reply)

Help Review This Startup / Best Core Java Tutorial That I Want To Share / How Do I Create MYSQL Root Password?

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 5
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.