Jump to content

  • Log In with Google      Sign In   
  • Create Account

Code Fox

Member Since 24 Nov 2011
Online Last Active Today, 09:59 PM

Topics I've Started

Can You Solve This 4th Grade Math Problem ?

20 November 2014 - 12:32 AM

Are you able to solve this 4th grade math problem ?

 It took me about 35 minutes to figure it out, maybe it will take you less time.




Java - Maximum Recommended Threads At One Time ?

16 November 2014 - 06:24 PM

On a normal computer ( 2.6 GHZ processor, 2 GB RAM ), how many threads do you think can be running at one time without causing system issues ?


 For you's who are going to ask - I use threads for event timing purposes . There could ( theoretically ) be over 40,000 "events" within each  player's rendered area .

Undesired Behavior When Attempting To Find Which Directory Jar Is Located In

29 October 2014 - 05:06 AM

 I have been writing a program that ( so far ) sorts out all the sub directories inside of the same directory were the .jar file is executed .

Unexpected behavior has popped up unfortunately.

 These undesired behaviors are as follows:

1: When testing this in Eclipse I get a list of the files inside of the package

2: After compiling the .jar file, I get null pointers errors when executing the program .


 What am I doing wrong here, and how to correct it ?

public class Files {
    File rawFiles;
    List <File> fileList;
    List <File> dirList;
    List <File> outGoing;
    String temp[];
    Scanner scan;
    public Files() throws Exception{
        String x = Files.class.getProtectionDomain().getCodeSource().getLocation().getPath(); // get path were .jar is
        String path = URLDecoder.decode(x, "UTF-8");
        scan = new Scanner(System.in);
        rawFiles = new File(path);
        fileList = new ArrayList<File>( );
        dirList = new ArrayList<File>();
        outGoing = new ArrayList<File>();
        fileList = (Arrays.asList(rawFiles.listFiles() ) );
        for ( int i = 0; i != fileList.size(); i ++ ){ // build list of all directories
            if (fileList.get(i).isDirectory() ){
                dirList.add(fileList.get(i) );
        } // End of for
        for ( int i = 0; i != dirList.size(); i ++){ // filter out empty directories
            temp = dirList.get(i).list(); // dirList.get(i).length DOES NOT WORK !!!

            if ( temp.length > 0){
                System.out.println("Added directory to processing list: " + dirList.get(i).getName() );
                System.out.println("Removed empty directory from list: " + dirList.get(i).getName() );
        } // End of for
        scan.nextLine(); // pause execution before closing

Is Self Optimizing Code Really Possible Now-A-Days ?

28 October 2014 - 12:53 AM

There was a discussion some time ago about self morphing code, and how it's imposable with modern OS security features.

 Is it possible to "work around" this issue by having one program, write the code for another application ?



 I tested this theory on my own. I used Java and Python to quickly prototype, however this is aimed mostly at lower level languages ...

 The first experiment  I wrote a simple Python program that wrote a Java application using simple system information. It than compiled and executed the application using Python's system commands interface.

 In the second experiment I wrote a simple Java program that wrote another Java application based on basic system information. Using Java's Process Builder I auto compiled and executed the new program.


 Can this approach be used to write more complex programs that are optimized to the user's specific computer system ??? 

String Split With Different Milti-Character Delimiters

23 October 2014 - 03:26 AM

When attempting to parse an XML file, I have run into the issue of how to efficiently extract strings .

Using pure Java, without 3rd party libraries, what would be the best solution for extracting a string from between something like this:

<Foo> Hello Every Foo One </Foo>

 Thanks in advance.