XML Feeds

.

[java-dev] FileNotFoundException

topher lafata topher at topher.com
Thu May 29 09:40:21 MDT 2008


if you give an absolute path it should get you to the next step.  
otherwise  look into MaxSystem.locateFile()
t
On May 29, 2008, at 08:20 AM, @pach wrote:

>
> Hi, I'm new to max. I'm trying to make a mxj object to read a txt  
> file, but I didn't arrive to open the file.
> got this error :
> java.io.FileNotFoundException: ./enregitrements/ 
> benoit_25-05_perf.txt (No such file or directory)
> 	at java.io.FileInputStream.open(Native Method)
> 	at java.io.FileInputStream.<init>(FileInputStream.java:106)
> 	at java.io.FileInputStream.<init>(FileInputStream.java:66)
> 	at Replayer.read(Replayer.java:27)
> com.cycling74.max.MaxRuntimeException
> 	at Replayer.read(Replayer.java:30)
>
> here is my source code (yes, I know, it's not really clean code ^^) :
>
> import java.io.FileInputStream;
> import java.io.FileNotFoundException;
> import java.io.FileReader;
> import java.io.IOException;
>
> import com.cycling74.max.*;
>
>
> public class Replayer extends MaxObject {
> 	
> 	private int currentTime = 0 ;
> 	private FileInputStream f = null ;
> 	private int timestamp = 0 ;
> 	private Atom[] currentWords = null ;
> 	
> 	public Replayer (){
> 		super();
> 		declareIO(1,2);
> 		String rien = "" ;
> 		int[] rienNonPlus = {0, 0} ;
> 		currentWords = Atom.newAtom(rien, Atom.newAtom(rienNonPlus));
> 	}
> 	
> 	public void read (String filename){
> 		System.out.println (filename);
> 		try {
> 			f = new FileInputStream (filename);
> 		} catch (FileNotFoundException e) {
> 			e.printStackTrace();
> 			throw new MaxRuntimeException () ;
> 		}
> 	}
>
> 	
> 	private void readLine (){
> 		String word = "";
> 		char caract ;
> 		Atom[] ret = null ;
> 		// recupere timestamp
> 		try{
> 			caract = (char) f.read();
> 			while (caract != ' '){
> 				word += caract ;
> 				caract = (char) f.read();
> 			}
> 			timestamp = Integer.parseInt(word);
> 			word = "";
> 			
> 			// recupere adresse et arguments
> 			caract = (char) f.read();
> 			while (caract != '
> '){
> 				word += caract ;
> 				caract = (char) f.read();
> 			}
> 			currentWords = Atom.parse(word);
> 		}
> 		catch (IOException e){
> 			e.printStackTrace();
> 			outlet(1, "bang");
> 			throw new MaxRuntimeException();
> 		}
> 	}
> 	
> 	// lit et renvoi l'ensemble des lignes pour un temps donnée
> 	private void readLineB4Time(int time){
> 		while (time>timestamp){
> 			outlet (0, currentWords);
> 			readLine();
> 		}
> 	}
> 	
> 	public void inlet (int time){
> 		readLineB4Time (time);
> 	}
> }
>
> and I tried to load the file like this :
> (message : read filename)
>
> ----------begin_max5_patcher----------
> 488.3ocsU0zbaBCD8L7qPildzwAIK7G4V9Kzqoc7HCqsUFPhQRdJtYx+8hj.
> GJlT65VeQL7zxtqd58VdKNBuQUCFL5IzKnnn2hih7PNfn12ivk75rBtwGFNS
> UVBRKdRXOKTa834ZUE5n5fFM0VaQeStUT.n8fF5BsPHgL0AoOdZKXkFLMoia
> EJ45KFgCmzhuUIsFwOAOFcZRKr7PoPV.VS+Xa.UGrcnIiUaMjYC7v7jljgVN
> yul5Vmwllf9d6WIx8mW0lWefwv8ZFIuz2L3m0BdQ2NUba1dgbWuBvV3ZWDIk
> LrDtO483X2xjq79nDLF9N3r6CMvyQegf+KXK5nrE47ycJ4xm6PFrGqfvgFiO
> wfiRIycr.c1R2i.wPVdiThSJ5Te3KnftBoB8OKUXLWixBRE+k5hkehTg94Dy
> j9jiaiVC4UPXD1pg09FHLI7ild7LITY8qnuBUE7ifF+O65lcNoPRtEczjgT1
> Xzy7UAW0BO830Szj6gEa5ifTC6DVM3lKZdbCHUB6ZZ5CIoqq.8V27v6hMb0+
> aWXZv3QYIgGiaC8YvOMevON7Yzg+6boo4mBYc0ua7A5CWRNXrB4I24KenM5E
> zdQdNH6O8tTjWoDR6Iyxn2rWaO47mWrmFz326dZ08llZd483eU6NhyK
> -----------end_max5_patcher-----------
>
> any Idea?
> thanks,
> Thomas.
> _______________________________________________
> java-dev mailing list
> java-dev at cycling74.com
> http://www.cycling74.com/mailman/listinfo/java-dev




More information about the java-dev mailing list