Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Java] How do I convert a string into code?
#1
I'm working on something where I have to load some text from a file, parse it, and then insert that parsed text as code into an array.

For example, here's what the relevant part of my file might look like:

Code:
Recipe: new ItemStack(Item.paper, 1, 0); new ItemStack(Item.dyePowder, 1, 5);


Here's what I need the array to look like:

Code:
ItemStack[] testRecipe = ItemStack[]{new ItemStack(Item.paper, 1, 0), new ItemStack(Item.dyePowder, 1, 5)};

Here's what I would be getting with my current code:

Code:
ItemStack[] testRecipe = ItemStack[]{"new ItemStack(Item.paper, 1, 0)", "new ItemStack(Item.dyePowder, 1, 5)"};

How do I convert those strings into plain codetext? Is it even possible?
Reply


Messages In This Thread
[Java] How do I convert a string into code? - by Qwertygiy - 07-11-2012, 02:43 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)