How to Create a Undeletable and Unrenamable Folders in Windows

How to Create a Undeletable and Unrenamable Folders in Windows

  • Go to Start and then Click on Run
  • Type cmd and hit enter
  • Remember you cannot create Undeletable & unrenamable folder in your root directory (i.e. where the windows is installed) That means you can’t make this kind of folder in C: drive if you installed windows on C:
  • Type D: or E: and hit enter
  • Type md con\ and hit enter (md – make directory)
  • You may use other words such as aux, lpt1, lpt2, lpt3 up to lpt9 instead of con in above step.
  • Open that directory, you will see the folder created of name con.
  • Try to delete that folder or rename that folder windows will show the error message.

How to Delete those files

You can’t delete the file in normal way. So follow these steps
  • Open Command Prompt
  • Type D: ( if u created this type of folder in D: drive) & hit enter
  • Type rd con\ (rd – remove directory)
  • Open that directory and the folder will not appear because it is removed.

What is String in Java

Strings

Strings, which are widely used in Java programming, are a sequence of characters. In the Java programming language, strings are objects.

The Java platform provides the String class to create and manipulate strings.

Creating Strings

The most direct way to create a string is to write:

String greeting = "Hello world!";

In this case, “Hello world!” is a string literal—a series of characters in your code that is enclosed in double quotes. Whenever it encounters a string literal in your code, the compiler creates a String object with its value—in this case, Hello world!.

As with any other object, you can create String objects by using the new keyword and a constructor. The String class has thirteen constructors that allow you to provide the initial value of the string using different sources, such as an array of characters:

char[] helloArray = { 'h', 'e', 'l', 'l', 'o', '.' };
String helloString = new String(helloArray);
System.out.println(helloString);

The last line of this code snippet displays hello.


Note: The String class is immutable, so that once it is created a String object cannot be changed. The String class has a number of methods, some of which will be discussed below, that appear to modify strings. Since strings are immutable, what these methods really do is create and return a new string that contains the result of the operation.


String Length

Methods used to obtain information about an object are known as accessor methods. One accessor method that you can use with strings is the length() method, which returns the number of characters contained in the string object. After the following two lines of code have been executed, len equals 17:

String palindrome = "Dot saw I was Tod";
int len = palindrome.length();

A palindrome is a word or sentence that is symmetric—it is spelled the same forward and backward, ignoring case and punctuation. Here is a short and inefficient program to reverse a palindrome string. It invokes the String method charAt(i), which returns the ith character in the string, counting from 0.

public class StringDemo {
    public static void main(String[] args) {
        String palindrome = "Dot saw I was Tod";
        int len = palindrome.length();
        char[] tempCharArray = new char[len];
        char[] charArray = new char[len];
        
        // put original string in an 
        // array of chars
        for (int i = 0; i < len; i++) {
            tempCharArray[i] = 
                palindrome.charAt(i);
        } 
        
        // reverse array of chars
        for (int j = 0; j < len; j++) {
            charArray[j] =
                tempCharArray[len - 1 - j];
        }
        
        String reversePalindrome =
            new String(charArray);
        System.out.println(reversePalindrome);
    }
}

Running the program produces this output:

doT saw I was toD

To accomplish the string reversal, the program had to convert the string to an array of characters (first for loop), reverse the array into a second array (second for loop), and then convert back to a string. The String class includes a method, getChars(), to convert a string, or a portion of a string, into an array of characters so we could replace the first for loop in the program above with

palindrome.getChars(0, len, tempCharArray, 0);

Concatenating Strings

The String class includes a method for concatenating two strings:

string1.concat(string2); 

This returns a new string that is string1 with string2 added to it at the end.

You can also use the concat() method with string literals, as in:

"My name is ".concat("Rumplestiltskin");

Strings are more commonly concatenated with the + operator, as in

"Hello," + " world" + "!"

which results in

"Hello, world!"

The + operator is widely used in print statements. For example:

String string1 = "saw I was ";
System.out.println("Dot " + string1 + "Tod");

which prints

Dot saw I was Tod

Such a concatenation can be a mixture of any objects. For each object that is not a String, its toString() method is called to convert it to a String.


Note: The Java programming language does not permit literal strings to span lines in source files, so you must use the + concatenation operator at the end of each line in a multi-line string. For example:

String quote = 
    "Now is the time for all good " +
    "men to come to the aid of their country.";

Breaking strings between lines using the + concatenation operator is, once again, very common in print statements.


Creating Format Strings

You have seen the use of the printf() and format() methods to print output with formatted numbers. The String class has an equivalent class method, format(), that returns a String object rather than a PrintStream object.

Using String's static format() method allows you to create a formatted string that you can reuse, as opposed to a one-time print statement. For example, instead of

System.out.printf("The value of the float " +
                  "variable is %f, while " +
                  "the value of the " + 
                  "integer variable is %d, " +
                  "and the string is %s", 
                  floatVar, intVar, stringVar); 

you can write

String fs;
fs = String.format("The value of the float " +
                   "variable is %f, while " +
                   "the value of the " + 
                   "integer variable is %d, " +
                   " and the string is %s",
                   floatVar, intVar, stringVar);
System.out.println(fs);







Reference : http://docs.oracle.com/javase/tutorial/java/data/strings.html

Android Project Folders:

First of all you need the Android SDK to get going. Download the relevant version for your platform. Currently it supoprts Windows, Linux and Mac. All right, got it done? Awesome, lets see the minimum you need to get started. Note that when you run the installer you will be presented with the following screen;

The rows i have marked with an arrow are the minimum elements you need to download in order to get started. Of course here i have presented my SDK manager in which i have installed almost everything. But that takes too much of time, and i know all of you do not have much time to spare. So just download the marked elements and lets get this show on the road!!!!
Got everything installed? Great, now lets set up our eclipse platform to start creating awesome android applications. Note that you require Eclipse 3.6 or higher to get the ADT ( Android Development Tools) plugin to work.

Go to install new software and add the location of the ADT plugin which is http://dl-ssl.google.com/android/eclipse . You only need to download the Developer tools from the ADT plugin because you will only need the NDK in a few instances. The NDK is the native development kit which allows you to program at a lower level using C language specifics. This post will only focus on the Android SDK.

So once you get that done you are ready to roll my friend. Before that i would like to mention a few things that are available to you after installing the Android SDK. You will have the SDK Manager and the AVD manager. The SDK manager will show any tools or APIs you need to download and you can use this tool to upgrade you environment as and when you need. We will get to the AVD manager when we look at the sample application.

In Eclipse, go to New->Other->Android->Android Application Project and follow the steps. Note that in the first screen you will have an option to specify the minimum required SDK. This signifies the minimum android SDK your application needs to run. Select the option ‘Create Activity’ and select the blank activity option. Give it a name and finish off the application creation process.

Now you will be presented with a structure as follows;

Lets take a look at what each folder is for.

assets : any property file, databases, text files or the sort which you want to bundle up with your application can be put here. This can have its own folder hierarchy within it self and you can read those files in the usual way you do file reading in java.

bin : contains the various files built by the ADT plugin. It will contain the .apkAndroid application package file)

gen : this folder contains mainly two files that are compiler generated. Which are R.java & BuildConfig.java. I will explain more about he R.java in a bit. It is best not to edit these files as these are anyway generated on each build.

libs : Contains the android jar that exposes the android APIs required for development. Note that in our application it uses the android-support-v4.jar which is the support version library that allows you to use newer APIs whilst having support for older Android Operating systems.

res : this folder contains all the resources required by your application such as images etc. You can categorize according to various screen resolutions, languages and OS versions. The layout folder will contain the XML file that allows you to define your UI element specific to your activity. The values folder allows you to define language entries in such a way we use .properties files in normal java applications to support different languages. More information can be found here.

src : contains the source files of your project.

AndroidManifest.xml : The manifest will define the name of the application, icon to be displayed, the various activities used, Permissions required etc. The version code is set to ’1′ initially. This code is used to determine whether your application has an upgrade available or not. Best practice is to increment the value on each release.

Within the manifest you can see an entry such as android.intent.action.MAIN. This signifies that the activity we just created is the main entry point of the application ( such as the main method in a java program).

R.java : This file is automatically generated and it is recommended that you do not change this file manually because anyway when you do any changes in your project, ADT will generate this file. This file provides access to the resources in your application in a programmatic way so that you can access your resources in a unified manner.

Let us open the blank activity that we just created. Ok the app here does not do much. But i just wanted to introduce the various elements that make up an android application and to jump start development. Within this sample what i show is how to call another activity from your main activity.

Let us first see the xml file pertaining to my main activity.

01 <RelativeLayout xmlns:android='http://schemas.android.com/apk/res/android'
02     xmlns:tools='http://schemas.android.com/tools'
03     android:layout_width='match_parent'
04     android:layout_height='match_parent' >
05
06     <Button
07         android:id='@+id/button1'
08         android:layout_width='wrap_content'
09         android:layout_height='wrap_content'
10         android:layout_alignParentLeft='true'
11         android:layout_alignParentTop='true'
12         android:layout_marginLeft='107dp'
13         android:layout_marginTop='134dp'
14         android:text='@string/next_activity_btn_name'
15         android:onClick='actClick'/>
16
17 </RelativeLayout>

As you can see nothing major here. Just one button which i have defined. The name of the button is defined in the strings.xml in order to make the application localization friendly. Also i have defined an onclick functionality. Let us see how the onClick method is implemented in my main activity:

01 package com.example.droidworld;
02
03 import android.os.Bundle;
04 import android.app.Activity;
05 import android.content.Intent;
06 import android.view.Menu;
07 import android.view.View;
08
09 public class DroidMainActivity extends Activity {
10
11  @Override
12  public void onCreate(Bundle savedInstanceState) {
13   super.onCreate(savedInstanceState);
14   setContentView(R.layout.activity_droid_main);
15  }
16
17  @Override
18  public boolean onCreateOptionsMenu(Menu menu) {
19   getMenuInflater().inflate(R.menu.activity_droid_main, menu);
20   return true;
21  }
22
23  public void actClick(View view) {
24   startActivity(new Intent('com.example.droidworld.NextActivity'));
25  }

You can see that the name of the on click method is the same as what i defined in the XML file. Also the method takes on the Viewclass as a parameter. Within this i use the method startActivity() which enables us to call another activity. Any name can be given here which should correspond to the name given in our application’s manifest.xml file. Let us see how we have defined this in our manifest;

1 <activity
2         android:name='.NextActivity'
3         android:label='@string/title_activity_next' >
4         <intent-filter>
5             <action android:name='com.example.droidworld.NextActivity' />
6
7             <category android:name='android.intent.category.DEFAULT' />
8         </intent-filter>
9     </activity>

Within the intent filter tags, the name given for the attribute android:name should correspond with the name given within our Intent() method within the startActivity method call. android.intent.category.DEFAULT allows another activity to call this activity. You can also get away by not defining intent filters if the activity you are going to call is within your own project. If that is the case then you call the activity directly as such;

1 startActivity(new Intent(this, NextActivity.class));

One thing to note here is that if you want to expose your activity to other applications, then you need to expose it using intent-filters.

That about winds up the introduction to the droid world. I myself am pretty new to this, so if you believe some of what i said in this post is invalid or requires changes, please do leave by a comment which is much appreciated.

You can download the sample project from here. You just need to do a Run->Android Application and you are good to go. Make sure to set up an AVD manager before running the application. The AVD manager creates the emulator on which your application is deployed. Create an instance by going to Windows->AVD Manager. The rest is intuitive so i will not go into detail. If you have any issues please do let me know and i will be glad to help.