나는 그것이 프로그램이 실행되는 모든 이미지의 크기를 조정하고 거기에 새로운 디렉토리를 생성하는 일식과 함께 컴파일하면 작동하는 것 같다 친구를위한 이미지 크기를 조정하는 프로그램을 썼다 새 크기 조정 된 이미지를 폴더에 저장합니다. 내가 자바를 내보낼 때Jar null 포인터 예외 자바 프로그램을 제공
는하지만 난 여기에 내가 (충분하지 않은 평판을) 언급 할 수 있기 때문에
" for (File file : allSubFiles) {"
도움말 pelase
public class Sample {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
String a = (Sample.class.getProtectionDomain().getCodeSource().getLocation().getPath());
File dir = new File(a+"resized");
dir.mkdir();
System.out.println(a);
File tempfile = new File(a);
File[] allSubFiles=tempfile.listFiles();
for (File file : allSubFiles) {
if(file.isDirectory())
{
}
else
{
String temp = file.getAbsolutePath();
String substr = temp.substring(temp.length() - 3);
//System.out.println(substr);
if(substr.equals("png") || substr.equals("gif") || substr.equals("jpg") || substr.equals("bmp"))
{
//System.out.println(file.getAbsolutePath()+" is file");
BufferedImage bufimage = ImageIO.read(file);
BufferedImage newImage = new BufferedImage(90, 90, BufferedImage.TYPE_INT_RGB);
Graphics g = newImage.createGraphics();
g.drawImage(bufimage, 0, 0, 90, 90, null);
g.dispose();
File outputfile = new File(a+"resized/"+file.getName());
ImageIO.write(newImage, "png", outputfile);
}
}
}
}
}
글쎄, 디버깅은 무엇을 찾나요? –