|
Found another method, using the FileChannel for transfering bytes.
|
|
|
|
|
I'm not sure if this is the right forum, as this might be related to either NFS or the underlying FS, but anyways...
I'm going through a number of Folders to find subfolders and the files in those subfolders:
Media_Folder1
|-> subfolder_1 -> File1, file2, etc...
|-> subfolder_2 -> File1, file2, etc...
Media_Folder2
|-> subfolder_1 -> File1, file2, etc...
|-> subfolder_2 -> File1, file2, etc...
...
I use the following code:
File rFolder = new File("/Media_Folder/");
File[] subFolderArray = rFolder.listFiles();
for (int i = 0; i < subFolderArray.length(); i++) {
if (subFolderArray[i].isDirectory()) {
File[] tmpFolderContent = subFolderArray[i].listFiles();
for (int i2 = 0; i2 < tmpFolderContent.length(); i2++) {
myCustomFileClass tmpCustFile = new myCustomFileClass(tmpFolderContent[i2].getPath());
}
....
The problem is that the code above (or a bit more complicated version) is working fine, until a certain point.
Then suddenly the tmpFolderContent array gives a nullpointer exception.
1. The code above (...and then some) creates a MediaObject that contains a StringArray that holds names of all subfolders.
2. Then the code goes through all those subfolders to create a CUSTOM FileObject array (Not the regular java.IO.File class, but a custom one that holds only enough info to create a new java.io.File object). The Custom FileObject ARRAY holds the filename and path of all files in all subfolders.
3. The number of files in each subfolder is never more than 25-30, and the number of subfolders is never more than 10, but the number of MediaObjects is fairly large (450++).
There are some ways I can go around this problem (Like add each object to the database right after it's creation [which is what I want anyways, although I want to do something more with the objects before I do this], but this means creating the objects, store them in DB, read them from db and then change them accordingly).
But I'd rather know what is causing this problem, so I know WHY I need to do it that way .
The strange thing is that it appears on the same media folder, and the exact same subfolder each time.
If I skip this folder, it happens on the next subfolder. So something is reaching it's limit.
I've also tried running the above code on ONLY the failing folder, and then it works just fine. So it's not access restrictions on the folders in question!
At first I thought it was the FileArray that had reached its end, but it has room for a lot more (I amped it up after hitting this problem).
Then I thought it could be the MediaObjectArray that had reached it's end, but after increasing it nothing changed.
So this leaves me 4 more possibilities:
1. The VM runs out of RAM? If so, how do I find/change the amount of RAM set aside for the VM (on Gentoo Linux)?
2. There's a limit to the number of file handles the VM can handle? If so, is there a way to change it?
3. Can the number of available FileHandles be defined by the underlying file system (In this case it's a remote NFS share on ReiserFS & XFS FS).
4. Or am I barking up the wrong tree here? Is there something obvious I'm not seeing here (as it often is ).
I guess it's not very good programming practices to create this many objects and to keep them in RAM like this, but I want to do some more stuff with the objects before they're added to the DB...and RAM means less waiting...
And this is my first Java Project, so give me some slack
Cheers,
Martin
|
|
|
|
|
Just a thought, but I think you may need to create new objects for both subFolderArray and tmpFolderContent before you make an assignment to them. You can't go past the end of the array since Java will take care of that sizing of the array for you.
AF Pilot
|
|
|
|
|
Your program will throw away every tmpCustFile object you create. Is this really what you intended?
Also, I think your //etc. part chopped off some important bits.
Also, why did you ignore standard naming procedures? myCustomFileClass should be MyCustomFileClass, to remind you that it's a class, not an instance.
You said:
TylerD75 wrote: At first I thought it was the FileArray that had reached its end, but it has room for a lot more (I amped it up after hitting this problem).
Then I thought it could be the MediaObjectArray that had reached it's end, but after increasing it nothing changed.
What are the two classes you mention? I did not see those anywhere in your code snippet.
From your words, you are storing objects somewhere. From your code, you are not. Please fix one or the other and maybe we can give a better answer.
Don't let my name fool you. That's my job.
|
|
|
|
|
Hi Guys, I am developing a system for my college's final year project and I plan to use JAVA for this ..
The topic of my system is a food ordering system, can i get some opinions from you guys...about ...
1. You guys should know, the GUI for a food ordering system is quite important since the application will be installed in the PC that placed at the table (in the restaurant), so the customer can order directly without the helps from the waiters, my problem is, Is Java good enough for developing such Strong GUI ? I have limited knowledge to Java may be, I found out that the Java's GUI (those built-in one like the provided by the JAVA APIT) is quite bored.... it not really looks like something that is for strong User Interaction....
2. Regarding to question 1, if I develop this food ordering system with java APPLET.... or the JAVA FX... will it be better?
Guys... I need your opnions ^.^" any opinions regarding to this food ordering system..... thanks for the time to read this message...
|
|
|
|
|
You don't have to develop your Java app just for the Web, you can make it a stand-alone app and run it on your PC, and if you have the PC networked (let's say to the "kitchen"), then the order can be read there and processed. I would suggest you take a look at www.java.sun.com --- there are many tutorials on there, and if you want a web-based app, they have an "ordering system" tutorial, with code, that you can base your application on.
Good luck!
AF Pilot
|
|
|
|
|
this is my first smart card project. i have to program the card in java using the API,i want the code that will allow the card to communicate to the pc.pls the code should support the API . that is what i am required to use for the project.
thank you.
|
|
|
|
|
what type/brand etc of smart card ?
Most of these gizmo's come with some sort of API from the manufacturer that has samples of how to use it - so the manufacturer's web-site or rep will usually be able to help you
'g'
|
|
|
|
|
i want to know the code of Find numbers in a given string with java
|
|
|
|
|
what kind of number ? integer ? float ?
Integer i = Integer.parseInt("4");
|
|
|
|
|
I don't find a suitable method to write ArrayLists to a text file. Does each attribute of the class objects that make up the ArrayList have to be written separately? When I wriye the class object of the ArrayList, it just writes out the memory location. Any advice would be much appreciated.
Thank you.
AF Pilot
|
|
|
|
|
you have to loop through the array list and get each array and print it through loop two
for example
private void printArryList(ArrayList<string[]>someList)
{
int counter=0;
for (int i = 0; i < someList.size(); i++) {
System.out.print("["+(++counter)+"]");
for (int j = 0; j < someList.get(i).length; j++) {
System.out.print(someList.get(i)[j]+" ");
}
System.out.println();
}
}
|
|
|
|
|
Thank you very much. I couldn't find much about writing out an ArrayList to a file in any of the Java documentation or tutorials (that appeared understandable to me, anyway). Much appreciated.
AF Pilot
|
|
|
|
|
Hello Friends,
I am looking for a solution to extract following meta data information from WMV file
1. Width
2. Height
3. Duration
4. Bit Rate
Can anyone please suggest me how I can start my RnD journey to achieve this solution.
Any help would be highly appreciated.
Thank You,
Java Developer - First Time
|
|
|
|
|
i dont know the exact program , but still i use Mediainfo . To download mediainfo.exe it will shows bitrate , size,bandwodth .. etc..
Thanks
mani.G
|
|
|
|
|
You need to learn about the format itself. Try Wikipedia for starters:
http://en.wikipedia.org/wiki/Windows_Media_Video[^]
Once you know the format, you'll need to look into Java file handling routines.
Don't let my name fool you. That's my job.
|
|
|
|
|
Hello guys
i am new to java and i have some problem that going to make my head explode
i am stuck on this thing for a week now
i need to read data file by column not by lines
for example
i have the following data file
6, 148, 72, 35, 0, 336, 0627, 50, 2
8, 183, 64, 0, 0, 233, 0672, 32, 2
1, 85, 66, 29
1, 89, 66, 23, 94, 281, 0167, 21, 1
0, 137, 40, 35, 168, 431, 2288, 33, 2, 10, 9, 125
5, 116, 74, 0, 0, 256, 0201, 30, 1
i need to read it coulmn by coulmn and store it to arrays
for exaample the first array would be {6,8,1,1,0,5} and so on
all what i have done is read it line by line and thats not working for me
this what i've done so far
public class VariableTransformation
{
private String FileName = "";
private FileReader FileReader;
private BufferedReader buffFile;
private ArrayList<string[]> attrDomainList = new ArrayList<string[]>();
private String[] item=null;
public static void main(String[] args)
{
VariableTransformation tds = new VariableTransformation();
Scanner input=new Scanner(System.in);
System.out.println("===============================================");
System.out.print("Enter the file name>> ");
String filename;
filename=input.next();
tds.fileLoad(filename);
System.out.println("===============================================");
}
public void fileLoad(String fileName)
{
String line = "";
String[] attrDomain;
FileName = fileName;
System.out.println("> Reading File..");
try {
int lineCount=0;
int size=0;
FileReader = new FileReader(FileName);
buffFile = new BufferedReader(FileReader);
try {
while((line = buffFile.readLine()) != null)
{
item = line.split(",");
size=item.length;
attrDomain=new String[size];
for (int i = 0; i < item.length; i++) {
attrDomain[i]=item[i];
}
attrDomainList.add(attrDomain);
lineCount++;
}
printData(attrDomainList);
System.out.println("> Finish File Reading.");
System.out.println("Number of Lines>> "+lineCount);
System.out.println("===============================================");
}
catch (IOException e) {
System.out.println(e.getStackTrace().toString());
System.out.println("# Error while reading file .");
}
finally
{
try {buffFile.close();} catch (IOException e) {e.printStackTrace();}
try {FileReader.close();} catch (IOException e) {e.printStackTrace();}
}
} catch (FileNotFoundException e) {
System.out.println("> Error. Target File Don't exist.");
e.printStackTrace();
}
}
private void printData(ArrayList<string[]> dataFile )
{
int Counter=0;
for (int i = 0; i < dataFile.size(); i++) {
System.out.print("["+(++Counter)+"] ");
for (int j = 0; j < dataFile.get(i).length; j++) {
System.out.print(dataFile.get(i)[j]+" ");
}
}
}
}
HELP PLEASE
|
|
|
|
|
|
you're on a forum for help about Java programming... so, what's your question ?
|
|
|
|
|
My question was what Java-programmers think about unusual approach to Java-programming which is described in the article above
|
|
|
|
|
On other forums, this might get modded down as "Unworthy Self Link". I think you should not have posted it here.
As for the article, a brief skimming leaves me quite confused. I think you need more organization. At what point do you show how to write C-style programs? And why do you think those are different from Java, which is already C-style?
Are you planning to write a big main() block of straight line code? I do not see the advantage of that. Teaching bad coding practices to Java beginners seems like a really inappropriate thing to do.
Don't let my name fool you. That's my job.
|
|
|
|
|
I make an excuse for tempering you (as the other forum members) for advertising my article. It is not because lack of modesty but more because I am very old programmer and still consider all kind of forums as public bulletin boards. The times changed, I see it now. The article is addressed to MPU-programmers, who know classical C and don't want to learn Java. The problem is: simple and cheap Cellular Phone is very userful device for MPU-programmes but its software includes only J2ME. I suggest the way for them to use Cell Phone (not Java) as device communicating with MPU's. I posted my link on Java pages to get professional critics of my sourse-code which to my mind has many interresting solutions. I had no intention to teach Java programmers.
|
|
|
|
|
or even further to my BBS days, cross-posting in inappropriate forums was still a big no-no.
I suppose you may have come from pre-Darpanet days when there were no such things as topics. Maybe while you were dodging dinosaurs you'd post wherever you could as fast as possible, just in case a sabre tooth tiger came along or a mammoth tromped on you.
But, yeah, even the earliest versions of America Online had rules. Somehow you missed those...
Don't let my name fool you. That's my job.
|
|
|
|
|
Here's what I'm using to change out the image content in an iframe,
client really needs to have each image linkable, is it possible to add a url variable and array to make each image on click go to a specific URL?
Tryed a few things with my limited java knowledge and can't seem to make it happen.
Any help/suggestions wickedly appreciated!
Script:
<script type="text/javascript">
<!--
function showImage(imgName) {
var curImage = document.getElementById('screenImg');
var curUrl = document.getElementById('screenUrl');
var thePath = 'img/';
var theSource = thePath + imgName;
var theTarget = 'screenImg'
curImage.src = theSource;
curImage.alt = imgName;
curImage.title = imgName;
curImage.target = imgTarget;
}
//-->
</script>
Html:
<iframe src="img/image1.jpg" width="500" height="200" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" name="screenImg" id="screenImg" class="scframe"></iframe>
<a href="#" onMouseOver="showImage('image1.jpg');">Link 1</a><br />
<a href="#" onMouseOver="showImage('image2.jpg');">Link 2</a><br />
<a href="#" onMouseOver="showImage('image3.jpg');">Link 3</a><br />
<a href="#" onMouseOver="showImage('image4.jpg');">Link 4</a><br />
<div class="ForumMod">modified on Wednesday, January 14, 2009 2:41 PM</div>
|
|
|
|
|
|