• Post Reply Bookmark Topic Watch Topic
  • New Topic

Some questions for a simple Java Program i want to make  RSS feed

 
Max Winfield
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Guys,

i am relatively new to Java and want to make a specific program.

What i want to do is that i have multiple zip files in a folder. The program creates empty txt file duplicates with all info about the originals contained in the filename.

For example:

Test.zip   (Contains 20 files and is 145,213,321 bytes long)

will create an empty txt file named:

Test, 20 files, 145,213,321 bytes.txt

and that for variable amount of zips i put in a specific folder.

The specific problems i have is how to do the following:

The Program should:

1. Read the filenames of .zip (perhaps .rar too) files in a specific folder
2. Create for every zip file an empty  .txt file and use the zipfilename for naming it ( so it is an empty same named txt file of the zip file)
3. Read the number of files contained in the zip file and put it into a variable
4. Read the byte size of every zip file in a variable

Thank you very much!!!

 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

This seems like a very strange thing to do, can you explain why you want to create empty text files named with details of a zip file?

We won't write the code for you but we will help you to write it, what do you have so far?
 
Max Winfield
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read comics (mangas) which are stored in zips and i want to delete them after i read them. So that i know and dont forget what i read and what not i until now created manually a text file for every zip, copied the filename and some infos (number of files contained and size into the filename of the empty txt file) after reading the manga i delete the zipfile to save space and keep the empty txtfile as reference to what i read.
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouldn't it be better to have one text file (possibly called something like "Comics I Have Read.txt") that holds all this information. You can append a new line of data for each zip file you want to delete.

If you format the data correctly for example as comma separated values you would then be able to load the file into programs that accept CSV files such as Excel.
 
Max Winfield
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did it that way because if done manually by hand you leave the alphabetical sorting to windows. For Example i have 1000 txt files and create a new one that starts with the letter o second letter m for example than i dont have to look where to place the new input into the one txt file. And on the other hand i can search with windows for filenames so i can use that. I am not so familiar with Excel either.
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Max Winfield wrote:
The specific problems i have is how to do the following:

The Program should:

1. Read the filenames of .zip (perhaps .rar too) files in a specific folder
2. Create for every zip file an empty  .txt file and use the zipfilename for naming it ( so it is an empty same named txt file of the zip file)
3. Read the number of files contained in the zip file and put it into a variable
4. Read the byte size of every zip file in a variable


Well, of the four items in the request, the latter three are easy (in comparison). The first one is a bit harder. You can do some research regarding the classes in the java.util.zip package -- which contain support for zip files. I don't know if there is any support for the RAR format though.

Henry
 
Max Winfield
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
until now i have the following which puts out the name of the zip files on the console for the folder C:\test


 
Max Winfield
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A specific Problem i have now is the following:

1. I have several zip files in one Directory.
2. I want to get the filecount of the files contained in each zip file and put the filecountvalues in an array.

ZipFile.size() seems to do the job for a single file. Example:



But i want **not** only the value of a **specific** file but the filecountvalues of several Zipfiles in a directory.


(would be best if i could use a java.io.File Object containing the entire "c:/test/" directory



but the Zipfile constructor seems to need a specific zipfile and cannot use the java.io.File "folder" Object or an entire directory and put the values in an array)
 
Max Winfield
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got the values i need now i just have to look how to create a text file and put the values in the filenames. (^_^)
 
Knute Snortum
Sheriff
Posts: 4270
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you trying to list all files that end is ".zip", or look into the zip files themselves? Nevermind, I didn't see the latest posts.

you should be able to create a file with Files.createFile().
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!