Ok im using netbeans and everytime i try input a file or anything i have to put the whole file path...which means none of my programs will be universal. example:
File file = new File("mgmt.jpg");
doesn't work...ever. even when mgmt.jpg is in netbeans in my project folder in my list of files under my java package.
File file = new File("C:/Users/Cameron Hussey/Documents/NetBeansProjects/pic2text/src/pic2text/mgmt.jpg");
i have to put this...which means noone can use my project.
why is this happening? this is something that shouldn't even be a problem , that noone should ever have to post on a forum about. but apparantly i do...any ideas guys? here is my whole code...it's a picture2text converter.
package pic2text; import java.io.*; import java.awt.*; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; public class pic2text { public static void main(String args[]) throws IOException { BufferedImage image = null; File file = new File("mgmt.jpg"); if (file.exists()) { image = ImageIO.read(file); } else { System.out.println("doesn't exist man"); } int w; int h; int clr = 0; String xline = null; String chars = null; for (h = 0; h < image.getHeight(); h+=2) { //System.out.println(clr); for (w = 0; w < image.getWidth(); w+=2) { clr = image.getRGB(w, h); switch (clr / -1350000) { case 0: chars = "$"; break; case 1: chars = "$"; break; case 2: chars = "@"; break; case 3: chars = "@"; break; case 4: chars = "%"; break; case 5: chars = "%"; break; case 6: chars = "H"; break; case 7: chars = "#"; break; case 8: chars = "#"; break; case 9: chars = "*"; break; case 10: chars = "*"; break; case 11: chars = "+"; break; case 12: chars = "+"; break; case 13: chars = "-"; break; case 14: chars = "-"; break; case 15: chars = "."; break; case 16: chars = "."; break; } xline = xline + chars; } System.out.println(xline); xline = null; } } }