링크 ux 자바 네트워크 그림 축소 오류

//     windows       linux                          
public boolean saveUrlAs() //fileUrl       
		{
			
			         String fileName = "123.jpg";	
			
			         String savePath="e:\";

		                  String fileUrl=http://www.baidu.com/1.jpg;

			try {
				//          ,    url 
				URL url = new URL(fileUrl);
				
				 //                 ,     in    url           
				HttpURLConnection connection = (HttpURLConnection) url.openConnection();
				DataInputStream in = new DataInputStream(connection.getInputStream());
				
				 BufferedImage src = javax.imageio.ImageIO.read(in);
			  
			        //             
			        BufferedImage tag = new BufferedImage(156, 117, BufferedImage.TYPE_INT_RGB);   
			        //           
			        
			        Graphics g = tag.getGraphics();
			        g.drawImage(src,0,0,156,117,null);
			        g.dispose();
			        File f = new File(savePath);
			        ImageIO.write(tag, "jpeg", f);

				
				
				return true; //               true 

			} catch (Exception e) {
				System.out.println(e);
				return false;
			}
		}


 

좋은 웹페이지 즐겨찾기