Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9125699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:51:49+00:00 2026-06-17T06:51:49+00:00

In java i’m used to using the built in classes for reading and writing

  • 0

In java i’m used to using the built in classes for reading and writing properties files but something similar doesn’t exist for lua.

Whats the simplest way to save a name and a value to file and then get the value back using the name?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:51:50+00:00Added an answer on June 17, 2026 at 6:51 am

    The simplest way would be something like this:

    local name, value = "abc", 123
    local f = io.open("outfile", "w")
    f:write("return {" .. name .. " = " .. value .. "}")
    f:close()
    
    ---
    
    local t = dofile("outfile")
    print( t[name] )
    --> 123
    

    This works, but isn’t very secure as dofile() just executes whatever Lua code it finds in the file. If the file returns a table full of your saved values as it does here then it works just great, but someone could easily edit this file to contain os.execute("sudo rm -rf /") or other such delightful fun.

    It’s possible to make this more robust with judicious use of setfenv() and debug.sethook(), but if you want to do it properly you should use one of the many serialisation libraries for Lua, a selection of which can be found here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Java doesn't support multiple inheritance for abstract classes, but I'm trying to do the
java.nio.file.Files.newByteChannel returns SeekableByteChannel . But actual class of the object returned is sun.nio.ch.FileChannelImpl (in
I have thousands of HTML files to process using Groovy/Java and I need to
Java has file related exception classes. Do C++ or Qt have similar classes?
Java DataInputStream class method readFully is used for reading the bytes from the stream
Java is the key here. I need to be able to delete files but
Java, how do I create a hash map outside of main but refer to
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
java - xpath - pom.xml I am using following pom.xml file as xml dom
Java - Jsch sudo command. I am using Jsch and my task is to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.