|
Java言語のソースコード整形例 |

 |
|
|
|
|
SourceFormatX は優れた構文解析エンジンを元に作られています。ですのであらゆるスタイルで書かれたソースコードを美しく整形することができます。以下の例のようなめちゃくちゃなコードでさえも、整形することが可能です。
|
これは極端な例ですが。SourceFormatXに搭載されている強力な Java言語 のパーサーエンジンの実力を感じて頂けるかと思います。
package cryptix.examples;import java.io.FileInputStream;import
java.io.IOException;import cryptix.security.MD5;
/** This is a demo of how to use the MD5 or SHA1 classes for hashing data **/
public final class MD5AFile{private static final int BUF_LENGTH=1024;public
static void main(String argv[]){if(argv.length!=1)System.err.println(
"usage java MD5Afile filename");else try{printHash(doHash(argv[0]));}catch(
IOException ioe){System.err.println(
"There has been an IO exception to the file was not hashed.");
ioe.printStackTrace();}}private static void printHash(byte buf[]){
System.out.println("hash of file is;");System.out.print("MD5 : ");for(int i=0,j
=buf.length;j>0;i++,j--){int val=(int)buf[i];System.out.print(Integer.toString(
(val>>4)&0xF,16));System.out.print(Integer.toString(val&0xF,16));}
System.out.println();}}
package cryptix.examples;
import java.io.FileInputStream;
import java.io.IOException;
import cryptix.security.MD5;
/** This is a demo of how to use the MD5 or SHA1 classes for hashing data **/
public final class MD5AFile
{
private static final int BUF_LENGTH = 1024;
public static void main(String argv[])
{
if (argv.length != 1)
System.err.println("usage java MD5Afile filename");
else
try
{
printHash(doHash(argv[0]));
}
catch (IOException ioe)
{
System.err.println(
"There has been an IO exception to the file was not hashed.");
ioe.printStackTrace();
}
}
private static void printHash(byte buf[])
{
System.out.println("hash of file is;");
System.out.print("MD5 : ");
for (int i = 0, j = buf.length; j > 0; i++, j--)
{
int val = (int)buf[i];
System.out.print(Integer.toString((val >> 4) & 0xF, 16));
System.out.print(Integer.toString(val & 0xF, 16));
}
System.out.println();
}
}
再び手動でJava言語のソースコードを整形するために時を浪費しないで下さい! SourceFormatX体験版の無料ダウンロード!
|