|
| |||||||||
| Tags: buffered reader, file, file system, inputout, javaio |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| BufferedReader can not find file
Hello, I have a package where I placed the files. I think in my code the BufferedReader can not find the file. Code: BufferedReader in = new BufferedReader(new FileReader("path of the directory")); Code: getClass.getResource("path of the directory ") |
|
#2
| |||
| |||
| Re: BufferedReader can not find file
Hello, Try the following method Code: getClass().getClassLoader().getRessourceAsStream("your directory"); |
|
#3
| |||
| |||
| Re: BufferedReader can not find file
Hello, I need to try the following in your code Code: getClass.getResources ( "your path to the directory "); |
|
#4
| |||
| |||
| Re: BufferedReader can not find file
Hello, Even i am facing a similar kind of a problem. I have tried these , but unfortunately they do not work for me 1) because it returns a URL; 2) because even if I do Code: getClass.getResources ( "path to the directory"). toString (); |
|
#5
| |||
| |||
| Re: BufferedReader can not find file
Hello, See if the following code works for you. Here it is Code: BufferedReader buff = null;
BufferedWriter buffout = null;
String s = null;
try {
buffout = new BufferedWriter (new FileWriter("tmp.tmp"));
InputStream input = getClass().getResourceAsStream("path to the direcotyr ");
int i;
while ((i = input.read())!=-1)
buffout.write(i);
buffout.close();
input.close();
buff = new BufferedReader(new FileReader("tmp.tmp"));
/ **
treatment on the binary
* /
} catch (IOException ex) {
ex.printStackTrace();
}
File f = new File("tmp.tmp");
f.delete(); |
|
#6
| |||
| |||
| Re: BufferedReader can not find file
Hello, Here is the more generalized form of the code. Code: try {
BufferedReader in = new BufferedReader(
new InputStreamReader( getClass().getResourceAsStream("path to the direcotyr ") ) );
try {
/ **
treatment on the binary
* /
} finally {
in.close();
}
} catch (IOException e) {
e.printStackTrace();
} |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "BufferedReader can not find file" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Closing the bufferedreader | Vodka | Software Development | 5 | 27-01-2010 12:21 PM |
| Problems with BufferedReader | Remedy | Software Development | 5 | 25-01-2010 11:42 AM |
| Problem in BufferedReader | SoftWore | Software Development | 3 | 02-12-2009 01:18 PM |
| find file containing text inside the file | pacinitaly | Vista Help | 0 | 22-10-2009 07:42 AM |
| Office 2003 Set-up stalls: Says it can't find file -- but file is really there! | Clueless in Seattle | Window 2000 Help | 2 | 03-06-2006 06:35 PM |