0

i am getting java.lang.NullPointerException for below code. Don't know where is the mistake. please look at the below code. I am trying to split video into specified size.

import java.io.*; class Split { public static void main(String args[])throws IOException { Console con=System.console(); System.out.println("enter the file path"); String path=con.readLine(); File f= new File(path); int filesize=(int)f.length(); try (FileInputStream fis = new FileInputStream(path)) { int size; System.out.println("enter file size for split"); size=Integer.parseInt(con.readLine()); byte b[]=new byte[size]; int ch,c=0; while(filesize>0) { ch=fis.read(b,0,size); filesize = filesize-ch; String fname=c+"."+f.getName()+""; c++; FileOutputStream fos= new FileOutputStream(new File(fname)); fos.write(b,0,ch); fos.flush(); fos.close(); } } } } 
3
  • Please cut and paste full output error. Commented Mar 8, 2015 at 15:31
  • How are you running this code? Is it from console of from IDE like Eclipse? Commented Mar 8, 2015 at 15:31
  • run: enter the file path Exception in thread "main" java.lang.NullPointerException at Split.main(Split.java:12) Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds) Commented Mar 8, 2015 at 15:33

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.