File access to /res folder before decompression

Hi, anyone please assist on how i would access a compressed text file in the /res folder before I can decompress it. I also need to know if its possible to create a file since the decompression algorithm creates a new decompressed file. The following code runs on a computer but I need to use it in the J2ME platform by calling it from the midlet class. Any assistance will be highly appreciated:
import java.io.*;
import java.util.*;
public class Decompress{
final static int MAX_CODES = 4096;
final static int BYTE_SIZE = 8;
final static int EXCESS = 4;
final static int ALPHA= 256;
final static int MASK = 15;
static int [] s;
static int size;
static Element [] h;
static int leftOver;
static boolean bitsLeftOver;
static BufferedInputStream in;
static BufferedOutputStream out;
private static void setFiles(String[] args) throws IOException{
String inputFile, outputFile;
if(args.length >= 1){
inputFile = args[0];
if(!inputFile.endsWith(".lzw")){
System.out.println("The filename must end with \"lzw\" extension");
System.exit(1);
in = new BufferedInputStream(new FileInputStream(inputFile));
outputFile = inputFile.substring(0, inputFile.length()-4);
out = new BufferedOutputStream(new FileOutputStream(outputFile));
else{
System.out.print("usage:java Decompress <filename>");
System.exit(1);
private static void output(int code)throws IOException{
size = -1;
while(code>=ALPHA){
s[++size]=h.suffix;
            code = h.prefix;
s[++size]=code;
for(int i=size; i>=0; i--)
out.write(s);
private static int getCode() throws IOException{
int c = in.read();
if(c == -1)return -1;
int code;
if(bitsLeftOver)
code = (leftOver<<BYTE_SIZE)+c;
else{
int d = in.read();
code = (c<<EXCESS)+(d>>EXCESS);
leftOver = d&MASK;
bitsLeftOver = !bitsLeftOver;
return code;
private static void decompress() throws IOException{
int codeUsed = ALPHA;
s = new int[MAX_CODES];
h = new Element[MAX_CODES];
int pcode = getCode(), ccode;
if(pcode>=0){
s[0] = pcode;
out.write(s[0]);
size = 0;
do{
ccode = getCode();
if(ccode<0)break;
if(ccode<codeUsed){
output(ccode);
if(codeUsed<MAX_CODES)
h[codeUsed++] = new Element(pcode, s[size]);
else{
h[codeUsed++] = new Element(pcode, s[size]);
output(ccode);
pcode = ccode;
}while(true);
out.close();
in.close();
public static void main(String [] args) throws IOException{
setFiles(args);
decompress();

if(messageNotWellFormatted("File access to /res folder before decompression"){
  retry();
}else{
  answerTo(post.getProfile());
}retry with the formatting tips !!!!!

Similar Messages

  • Audio file access

    I'm trying to access a .wav file from my hard drive and have been unsuccessful. I have the following code:
    String wav = "file:///c:/tada.wav";
    Player p = Manager.createPlayer(wav);
    When I run the application and click on the play button i get an error saying that it cannot connect to the file. but the code compiles fine. If I try to access a file that resides online it works fine. i.e. if I enter a url instead of file:///c:/tada.wav
    Any suggestions on how I should solve this problem? Should I throw this file in the 'res' folder and try to access it from there....how would do that then?

    Hi my friend,
    below is my code I think it will help you, where res is just a directory under my directory classes. Have fun.
    protected void startApp() {
    try {
    String type = "audio/x-wav";
    InputStream sourceStream = getClass().getResourceAsStream("/res/audio/bark.wav");
    Player player = Manager.createPlayer(sourceStream, type);
    player.start();
    }

  • How do i change the access rights for every file in every sub-folder?

    I have an external drive that was shared between my PC and my iMac (running Snow Leopard 10.6.5).
    Some of the files created by my PC have the following access rights (privileges):
    Me: Custom
    staff: Custom
    everyone: Custom
    I want every file to have the following access rights (privileges):
    Me: Read & Write
    staff: Read & Write
    everyone: Read & Write
    I presume that I need to go into the terminal and run some command line program, but I have no idea what program or what options (or even where to look for such a program). Can someone tell me how to do this, so that every file in every sub-folder has the same access rights?

    Well, that's different. Most people do not install anything on their PC to read an HFS+ disk, so I assumed it was formatted for the PC. [See my above post|http://discussions.apple.com/thread.jspa?messageID=12843313#12843313].
    Note that it is the same as what you asked about, except with numbers instead of the letter equivalents.
    Posix permissions are for User;Group;Other (ugo) and each one can have read/write/execute permissions. Read = 4, Write = 2, and Execute = 1. So, for rwx you set 421=7.
    I try to make it safe by not typing in the file path. If you do what you posted, you will change the startup volume's permissions. The path to your external is /Volumes/ext hd mount point. If you start typing the path and accidentally hit return before finishing the full path, you could fubar something you didn't want to. So, I type the command, leave a space, and then drag the target to the Terminal window.
    You might also consider the GUI based permission changing program, [BatChmod|http://www.macchampion.com/arbysoft/BatchMod/Welcome.html].
    Message was edited by: Barney-15E

  • Accessing the files in OBIEE deployment folder. IIS vs OC4J

    Hi,
    I want to access the files like CSS in the OBIEE deployment folder.
    I know how to access the files in the deployment folder when the application is hosted on IIS.
    For Example:
    I have Hosted a .net application on IIS.
    The application deployment folder is sampleApplication. The URL will be something like - http://localhost/sampleApplication/samplePage.
    And if i have a CSS file under Styles folder in sampleApplication folder, the file can be accessed Like - http://localhost/sampleApplication/Styles/style.css.
    I want to do the same for OBIEE hosted on OC4J. I want to access the CSS files through the URL.
    Where will be the CSS files and How will they be accessed through the URL.
    Http://localhost:9704/..??
    Thanks in advance.

    I found that filenames are case sensitive on the iphone but not on the simulator so check that.

  • How can I access my user folder on a second boot partition?

    Hi there. Thank you for reading this. I am at a bit of a loss although I have searched several forums to find someone having the same problem:
    I use my Macbook Pro in the office and at home. To keep things strictly apart and have to separate Time Machine backup procedures, I have divided my harddrive into two boot partitions ('office' and 'private') and installed Mountain Lion on both of them. Now occasionally when I am at the office I would like to access my  user folder on 'private' to retrieve a file from the documents folder there (e.g. a paper I gave in my free time but would like to send to a colleague). Now although I see the 'private' volume, and the other user folder and the Documents folder in it with a red 'No Access' badge, even when I  set read/write permissions via Command-I > Permissions for my current account, I do not see any files in it apart from Microsoft User Data. I have tried enabling the root user but with the sam result.
    Do I really have to shut down the computer and boot with the 'private' boot volume in order to access the files on 'private'>user?
    Looking forward to your suggestions! Thank you in advance!
    Christian

    To solve this issue permanently, is to first disconnect both TimeMachine drives.
    Boot into one partition and consider it history, make a note of everything, apps, export bookmarks, serial keys and files to a regular external drive. (non TimeMachine)
    If on a hard drive, consider the first partition for performance, the second one is going to be slower. (SSD no need)
    Next what you do is boot into the first partition and use Disk Utility to erase (with zero option if a hard drive) the other partition. Then use Carbon Copy Cloner to clone the first partition to the second. (should be about equal sizes or tweak before cloning.)
    Repair permissions on both partitions in Disk Utility.
    Next boot into the second partition and install/uninstall apps and files. etc and set it backup up the way you had it.
    Once your sure, then update TimeMachine for each one.
    Now you will be able to easily access the other bootable partition as long as your logged into the same account name on the first partition., in other words you can access the same named account on both partitions and trade files without rebooting.
    Because it's a clone, you have the same access privileges to the files on the other partition.
    If your a power user, your going to find bootable clones are a much superior option than TimeMachine
    Most commonly used backup methods

  • How to limit file access for different users in 10.7.4 Server

    We had everything working perfectly with an earlier version of Lion Server. The update to 10.7.3, or 4, seems to have opened access to all files for all users. Much to our surprise, this wide-open access started without warning.
    - We have an external drive that contains all of the company's archives
    - We had set access for one employee to get to the files he needs, and different access for another employee. Neither saw sharepoints outside of their access settings.
    After an update, each employee can see and log in to all sharepoints. There doesn't seem to be a way to limit access for each employee now. I can set 'read' access for one employee, but it doesn't stop the other employee from accessing that sharepoint/folder.
    Is there some new way to go about this? Or is something simply broken with the current release?

    That is good to know. If the file share is seeing the drive and ignoring its permissions, that is why everyone can see everything. I have found, in Lion Server, that it is best to get the permissions set before turning on File Sharing. I don't know if you have the luxury of turning the file share off for a little while, but I would unshare the drive and see if the issue persists if you plug the external drive into another machine. The settings for permissions are set on the file or folder itself, so the issue should follow you to the other machine.
    Again, if you can, I would unshare the drive and reshare it with the permissions that you want and turn file sharing back on. However, if you can get the drive to respect permissions rather than ignoring them, I think it will save you a lot of work.

  • Image file access dates changing in mass (Windows).

    In review of the access date properties for image files within a directory being accessed by Bridge within the Favorites area, they are all changing to the current time and date, even if the image is not viewed within Bridge.  Why are the access dates of image files being changed even though they are not viewed?  This makes it hard to determine whether an image can be archived or deleted based on last access if Bridge is always changing the access date every day.  Thanks for any insight you can give on this!

    Is there a way to turn off the caching of thumbs or metadata or whatever is causing the Access date to change when searching or reviewing images within a directory using Bridge?
    As said, no experience with network environment. But Bridge is a browser and when you want to view things it needs to cache the file and data first.
    Having said that, in normal usage (stand alone) it stores and saves this data in the cache folder and once it has done so it will not need to recache until you have made changes to the file. Check Bridge prefs / Cache/ Location  to see where the data is stored when you are using this machine.
    By default on a stand alone Mac (windows seems to have a similar cache file) it should be in the User Library/ caches/ Adobe/ Bridge CSxx and inhere is a plug in and a folder called Cache, containing several folders.
    For Bridge CC there are 4 folders, 256 (the cache files of the thumbs) 1024 (containing HQ preview cache files) data (what it says) and full (containing the 100% previews in cache)
    All files that have been fully cached (pointing to a folder the content window should show already good thumbs and the activity bar bottom left in Bridge window should not show any activity, only the number of items showing and items hidden) don't need to recache for that machine again unless you changed something to the file or added metadata.
    So once cached there should be no reason for Bridge to 'access' the file again unless access means looking for the file to check if the saved data still applies to the corresponding file on your machine, but then al files should show about the same access time because this is a very fast process on a fast machine.
    You can't deselect cache because as said Bridge is a browser showing the content of your files, and to show this it has to generate a thumb and if needed a preview. But as also said, once cached it normally should not start recaching until changes are applied.
    You have several ways to set the quality of the cache:
    There are two checker board icons top right that give you the option to set for cache. By default it is set to 'Always HQ' to have both good thumbs and a good preview when pointing to a file.
    Then you also have to option to generate 100 % previews which provides you with almost instant 100 % previews for loupe in preview panel or full screen view and click. Logically this needs more time and generates a lot of big cache files, all depending on the files you start with and the size of your monitor.
    Finally you have the option to use embedded previews only. This is a very quick method but provides low quality thumbs (black border around it) and when clicking on a thumb it first needs to generate a HQ preview that then will take time.
    In Bridge prefs advanced there is the option to create also monitor sized previews which should provide you with good quality full screen when using space bar in Bridge to preview in full screen.
    This setting also creates a bit larger cache files in the 1024 folder depending on the size of your monitor (logical).
    And if you want to apply a search using the find command you also have to include non indexed files to search in all folders, including the not before cached files.
    Like first time cache this first indexing takes some extra time but should only need to be done once and then be persistent until you add new files or folders that have not been cached or indexed before.
    Until so far the theory for a stand alone. If you have the files stored in a Network and other stations have access and have different cache settings or monitor size settings there might be some other things going on, or someone else has changed the file on their station and then when you select that folder Bridge needs to recache the changes.
    Hopefully this makes some sense for you?

  • File Access Denied Error trying to load Photoshop CS4 on Windows 7

    I am trying to load Photoshop CS4 on Windows 7 64bit & I keep getting File Access Denied. I am unable to read to the disk or to load the program. I do not have the option to open as administrator.

    So when you put the disk in it won't run correctly? When the disk is inserted you should have a window pop up with 2 options. 1 to install and the other to see what is on the disk. Choose to explore or open the disk. Go to the CS4 folder where the photoshop .exe file is (that will run the setup), right click on the .exe file and choose run as Admin and it should start. See if it will install. If not then read below.
    I am not sure how far you got in the install before so chances are you will have to run the CS4 cleanup utility. 2 levels to run at but don't use 1 or 2 just type in the number 3.
    http://www.adobe.com/support/contact/cs4clean.html
    You may need to run the windows installer cleanup utility too
    http://support.microsoft.com/kb/290301
    Before you try to reinstall the software ensure that adobe reader is not installed. If it is remove it. It has caused issues in the past with vista and CS4 installs.
    Also turn off windows Defender and any anti-virus software. You can keep UAC on in Windows 7.
    During the CS4 install at 90 percent it will almost stop and may take 5 to 10 mins to finish. This is normal. What a pain huh......
    After install is finished, reboot
    After reboot, go to the CS4 64 bit or 32 bit icon (depends on 32 or 64 bit Windows 7) in start area, right click on CS4 64 bit (if you have windows 7 64 bit) and choose properties, compatibility tab and then check run as Admin at the bottom area. Hit apply, ok to close out.
    Now start CS4 and run the updater.

  • I'm trying to download and run Firefox but keep getting an "error creating directory" message. C:\Program Files\Mozilla Firefox\res\dtd What do I need to do to fix this?

    It shows under the message, the following:
    C:\Program Files\Mozilla Firefox\res\dtd
    What do I need to do to fix this?

    * Download a fresh Firefox copy from http://www.mozilla.com/firefox/all.html and save the file to the desktop.
    * Uninstall your current Firefox version and remove the Firefox program folder before installing that copy of the Firefox installer.
    * Don't remove personal data if you uninstall the current version.
    * It is important to delete the Firefox program folder to remove all the files and make sure that there are no problems with files that were leftover after uninstalling.
    Your bookmarks and other profile data are stored elsewhere (not in the Firefox program folder) and won't be affected by a reinstall, but make sure that you do not select to remove personal data if you uninstall Firefox.

  • J2me file access problem

    hi,I try to read and write a file with j2me. The file which is file.txt in the root1 directory in filesystem.when running one emulator i can access the file,but running multi emulator cant access the file.Seeing "file not found" error.
    How can acces this file by two or three emulator?

    can u send me the code for reading a file from root in linux platform
    and how can i read a file that can travell within MIDlet suite like the images
    in /res folder mail me at [email protected] i have tried the following segment
    having no success
    public void writeFile()
    FileConnection fc;
    StreamConnection conn = null;
    InputStream is;
    try{  
    OutputConnection con =(OutputConnection)Connector.open("file:///root/riz.txt",Connector.WRITE);
    OutputStream out =con.openOutputStream();
    PrintStream ps = new PrintStream(out);
    ps.println("rizwan");
    ps.close();
    con.close();
    }catch (Exception e){System.out.println(e);}
    hoping for an early reply

  • Android res folder not included in the ane extension

    Hi.
    I am trying to develop an android extension fro air, but I have a problem with resources.
    According to this : http://help.adobe.com/en_US/air/extensions/WSf268776665d7970d-2e74ffb4130044f3619-7ff8.ht ml
    The res folder should be included inside the created extension. But it actually isn’t.
    for this test I simply use the basic Hello world Vibrate test, but I added a new png in the drawable folder.
    As you can see while unziping the .ane file, then going to META-INF/ANE/Android-ARM
    the res file is absent.
    As a result, the program crashes when I try to access my ressource FREContext.getResourceId("drawable.ppy_accessory_manage.png")
    Has anyone managed to make resources work with ANE in android?
    PS, here is my batch to compile the ANE :
    set adt_directory=C:\Program Files\Adobe\Adobe Flash Builder 4.6\sdks\4.6.0\bin
    set root_directory=C:\Users\hugo\Adobe Flash Builder 4.6
    set library_directory=%root_directory%\HelloANELibrary
    set native_directory=%root_directory%\HelloANENative
    set signing_options= -storetype pkcs12 -keystore "C:\Users\hugo\Adobe Flash Builder 4.6\certificat.p12"
    set dest_ANE=HelloANE.ane
    set extension_XML=%library_directory%\src\extension.xml
    set library_SWC=%library_directory%\bin\HelloANELibrary.swc
    "%adt_directory%"/adt -package %signing_options% -target ane "%dest_ANE%" "%extension_XML%" -swc "%library_SWC%" -platform Android-ARM -C "%native_directory%" library.swf HelloANENative.jar

    Answer given on stack overflow :
    http://stackoverflow.com/questions/8060041/adobe-air-3-native-extensions-android-res-folde r-not-included-in-the-ane-file

  • Restrict workgroup computers in accessing my shared folder

    How to restrict workgroup computers in accessing my shared folder.
    And only allow a specific system in the workgroup to have full control access to that shared folder.
    Operating System :Windows Server 2003

    Hi Tiju,
    You cannot restrict access to a folder using computer accounts. The access to the share folder can only giving to everyone or local accounts if the network environment is
    Workgroup.
    Because the computer account never tries to access the shared folders. The access attempt is made by the user account; and if the user account isn't in the ACL of the file, he won't get access.
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/57739cb5-ec63-403d-b2c5-3949d440a845/restrict-access-to-network-folder-in-workgroup?forum=w7itpronetworking
    Regards,
    Rafic
    If you found this post helpful, please give it a "Helpful" vote.
    If it answered your question, remember to mark it as an "Answer".
    This posting is provided "AS IS" with no warranties and confers no rights! Always test ANY suggestion in a test environment before implementing!

  • Cannot display the folder. Microsoft Outlook cannot access the specified folder location.

    Hi, guys
    I cannot view delegate mailbox in Outlook. Following is my configure.
    I have two mailbox A-User and B-User
    Login Outlook as A-User, click File -> Account Settings -> Delegate Access, add B-User and give Editor permission of Inbox.
    Right click A-User's root inbox and select Properties -> Permission, select B-User and check "Folder visible".
    Login Outlook as B-User on other computer, click File -> Account Settings -> Account Settings, select B-User and click Change -> More Settings -> Advanced, add A-User.
    Now I can see a root A-User in Navigation Pane. But when I click it, it shows
    "Cannot display the folder. Microsoft Outlook cannot access the specified folder location."
    or
    "Cannot display the folder. Microsoft Outlook cannot access the specified folder location. The operation failed. An object cannot be found".
    I searched some solutions from internet, but all of them don't work. Could you give some suggestions? 
    Thanks.

    Hi,
    First, please double check if you have given the right permission to B-User on your step 2.
    In addition, we can try to give a higher permission to the B-user to check the result.
    Please feel free to post back and let me know the result.
    Best Regards,
    Steve Fan
    TechNet Community Support

  • HT203200 Cannot delete the file from the itunes folder

    I cannont delete the file from the itunes folder because it tells me I need permission to do so.  I am the admin person for the laptop plus I have checked my permissions under the security tab in the files properties.  How do I delete this file to start again?  It downloaded 1.2GB of the file before the error message appeared, so its paid for and all but not looking like I'll get to watch it before the time runs out on the movie being available for me to watch. :-(

    Try deleting the file without iTunes running.
    When you next open iTunes it should then be marked as a missing file and you should be able to delete the entry from iTunes.
    Hope this works
    Regards,
    Colin R.

  • Delete files in /lib/ext folder

    I have an applet that used to install and use a third-party jar in /lib/ext. The jar is recently got upgraded but I have problem deploying the new jar file. Because the file is in /lib/ext, it is always loaded and used by JRE, I can't delete the file in code (it is locked). And because it is loaded by the system classloader which has the higher priority, custom classloader does not work either. Is there any way that I can deploy the new jar file without asking all user to manually delete the old jar from /ext/lib folder before running the applet?
    Thanks in advance!!
    Jack
    Edited by: suyuchieh on Jul 5, 2008 9:11 PM
    Edited by: suyuchieh on Jul 5, 2008 9:12 PM

    suyuchieh wrote:
    Yes, I agree that the jar should not be installed in that folder from the beginning (the applet had code to copy the jar to that folder whenever it is not there). There may be some historical reason but it is a problem now~As you've already noted, you can't while the applet itself is running, and you shouldn't be able to anyway. That would be a pretty lax security policy that allowed an Applet to write anywhere in the jdk/jre directories.
    Include a notice on the site that, if they have not already done so, that they should close the site, remove the jar, and then reconnect.

Maybe you are looking for