java 14

xls, xlsx 파싱(XSSFWorkbook, HSSFWorkbook, XLSParser)

라이브러리 필요 org.apache.poi poi 3.9 org.apache.poi poi-ooxml 3.9 // xlsx FileInputStream xlsxFile = new FileInputStream(new File(fileName)); // 파일 스트림을 XSSFWorkbook 객체로 생성 XSSFWorkbook workbook = new XSSFWorkbook(xlsxFile); // XSSFWorkbook 의 첫번째 시트를 가져옴 XSSFSheet sheet = workbook.getSheetAt(0); int xlsxRows = sheet.getPhysicalNumberOfRows(); for(int rownum=1; rownum

개발/java,spring 2016.04.16

[java]자바 파일 삭제

이번엔 파일과 하위 폴더들의 파일까지 삭제하는 과정을 알아보겠습니다.간단해서 그냥 텍스트로 소스를 적어보겠습니다. 소스public void deleteFolder(String parentPath) { File file = new File(parentPath); String[] fnameList = file.list(); int fCnt = fnameList.length; String childPath = ""; for(int i = 0; i < fCnt; i++) { childPath = parentPath+"/"+fnameList[i]; File f = new File(childPath); if( ! f.isDirectory()) { f.delete(); //파일이면 바로 삭제 } else { dele..

개발/java,spring 2016.04.06

[java]자바 파일 복사

프로젝트를 진행하다가 파일을 복사하여 다른곳으로 이동시켜야 하는 경우가 있어서 아래와 같은 함수를 만들었습니다. 그리고... 나중에 또 씌어질거 같아서 메모겸? 포스팅 합니다.은근히.. 파일 복사, 이동, 삭제의 기능이 많이 사용되네요.. 해당 디렉토리 생성하는 법도 알아 둘 필요가 있는것 같습니다. public void copyFile(File file, File mfile) throws IOException{ InputStream inStream = null; OutputStream outStream = null; try{ inStream = new FileInputStream(file); //원본파일 outStream = new FileOutputStream(mfile); //이동시킬 위치 byte..

개발/java,spring 2016.03.31