Java:获取本地文件

/**
 * Function:  todo
 *
 * @program: 获取本地图片
 * @Package: com.kingbal.king.dmp
 * @author: dingcho
 * @date: 2025/01/22
 * @version: 1.0
 * @Copyright: 2024 www.kingbal.com Inc. All rights reserved.
 */
@Slf4j
public class BaseTest {

	public static void main(String[] args) {
		File file = new File("/resource/images/kingbal_logo.jpg");
		InputStream in = null;
		try {
			byte[] tempbytes = new byte[100];
			int byteread = 0;
			in = new FileInputStream(file);
			while ((byteread = in.read(tempbytes)) != -1) {
				System.out.write(tempbytes, 0, byteread);
			}
			log.info("文件大小:{}" + file.length());
		} catch (Exception ee) {
			log.error("异常:{}", ee);
		} finally {
			if (in != null) {
				try {
					in.close();
				} catch (IOException e1) {
				}
			}
		}
	}

}

你可能感兴趣的:(Java,java,http)