简体   繁体   English

无法使用RandomAccessFile读取文件

[英]Can't read file using RandomAccessFile

I'm trying to read a file using Eclipse console directly via RandomAcessFile command. 我正在尝试直接通过RandomAcessFile命令使用Eclipse控制台读取文件。 Here's my line of code where I call for this: 这是我需要的代码行:

RandomAccessFile direcciones = new RandomAccessFile("direccionesRed.txt","r");

I'm getting an exception because Eclipse can't find the file and I need help about where to place it. 我遇到了一个异常,因为Eclipse找不到该文件,并且我需要有关将其放置在何处的帮助。 I have tried it placing copies into the 'bin' folder where .classes are placed, and into the folder where .java types are placed as well, but it doesn't seem to resolve the exception. 我已经尝试过将副本放置到放置.classes的'bin'文件夹中,以及放置.java类型的文件夹中,但是它似乎无法解决该异常。

Can I get help about where to place my txt file, or if there's other way to call my program to read my txt file? 我可以获取有关将txt文件放在何处的帮助,或者是否还有其他方法可以调用程序读取txt文件?

In order to don't modify my full code with Reader type; 为了不使用Reader类型修改我的完整代码; I've solved the problem replacing the txt file JUST into the same folder where all the folders of the project are (it means, next to your 'bin' folder, etc). 我已经解决了将txt文件替换为项目的所有文件夹所在的同一文件夹的问题(这意味着,在“ bin”文件夹旁边,等等)。 In other words, the difference between my first try and now, it's that I placed the files into the bin folder and my projects .java folders, and now they are placed just outside them. 换句话说,我第一次尝试和现在尝试之间的区别是,我将文件放置在bin文件夹和项目.java文件夹中,现在将它们放置在它们的外部。

This way, Eclipse console will read all your txt files properly. 这样,Eclipse控制台将正确读取所有txt文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM