Solved

Question with writing to files

Posted on 2002-07-01
6
186 Views
Last Modified: 2010-03-31
I want to know how to create text files with variable names.

For instance, let's say I want to create a text file called "File0".  Later I want to create a text file called "File1", and so on.

How would I create a file that has a variable in it's name that I can just keep incrementing?

I hope you guys understand what Im asking :)
0
Comment
Question by:lwinkenb
  • 3
  • 3
6 Comments
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 7123381
int n = 5;
File f = new File("File"+n);
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 7123430
Thanks objects.

How would I do the same thing for variable names?  Let's say I wanted to make a bunch of integers like

int integer0 = someRandomNumber;
int integer1 = someRandomNumber;
int integer2 = someRandomNumber;
...
0
 
LVL 92

Expert Comment

by:objects
ID: 7123438
you can't sorry.
Why not use an array instead:
int[] integer = new int[3];
integer[0] = someRandomNumber;
integer[1] = someRandomNumber;
integer[2] = someRandomNumber;
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 5

Author Comment

by:lwinkenb
ID: 7123451
Thanks objects.

How would I do the same thing for variable names?  Let's say I wanted to make a bunch of integers like

int integer0 = someRandomNumber;
int integer1 = someRandomNumber;
int integer2 = someRandomNumber;
...
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 7123708
Thanks again!
0
 
LVL 92

Expert Comment

by:objects
ID: 7123717
No worries, thanks for the points :)

http://www.objects.com.au/staff/mick
Brainbench MVP for Java 1
http://www.brainbench.com
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Securing Jmx Console and web console 2 48
maven example error 3 36
backtracking recursion  code 19 41
Java Jpanels and Jframe 8 21
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This video teaches viewers about errors in exception handling.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now