Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > I develop a Java program to format Java codes

Reply
Thread Tools

I develop a Java program to format Java codes

 
 
gearss8888@gmail.com
Guest
Posts: n/a
 
      03-02-2012
The program can format Java codes, the codes formatted will have correct indent spaces.

//----------
/*
Modified: 2012-3-1
it can format java codes so as to get the correct indent spaces.


*/
import java.io.IOException;//引入类
import java.io.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.InputStream;
import java.io.Reader;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.awt.Graphics;
import java.awt.Color;
import javax.swing.JFileChooser;
import javax.swing.SwingConstants;
import javax.swing.UIManager;

public class Tidy extends JFrame {
JButton SelectFilebtn, OKbtn;
JTextField FileNameField;
String TabBlank = " "; // 每一次tab的空格大小,这里为默认的四个空格
int HowManyTab = 0;
boolean HaveUnCleanRow = false; // 记录有没有编写不规整的程序代码,如果有弹出对话框请 用户改正再关闭控制台,如果没有,不显示对话框。
boolean ForWhileIfBlock = false; // 标志这一行是否for, while or if 开头但却没有{}符号,这说明这个块只有一行。
public Tidy () {
this.setTitle( "文件整理器");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.WEST; //设定Layout的位置
gbc.insets = new Insets(2,2,2,2); //设定与边界的距离(上,左,下,右)
SelectFilebtn = new JButton("选择文件");
SelectFilebtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
do_SelectFilebtn_actionPerformed(e);
}
});
FileNameField = new JTextField("",40);
gbc.gridy=1;
gbc.gridx=0;
this.add(SelectFilebtn, gbc);
gbc.gridx=1;
this.add(FileNameField, gbc);
//--------------
OKbtn = new JButton("OK");
OKbtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String FileName = FileNameField.getText();
do_OKbtn_actionPerformed(e, FileName);
}
});
gbc.gridy=2;
gbc.gridx=0;
this.add(OKbtn, gbc);
//---------------------
this.pack();
this.setVisible(true);
}

protected void do_SelectFilebtn_actionPerformed (ActionEvent e) {
JFileChooser chooser = new JFileChooser();// 创建文件选择器
int option = chooser.showOpenDialog(this);// 显示文件打开对话框
if (option == JFileChooser.APPROVE_OPTION) {// 判断用户是否选定文件
File file = chooser.getSelectedFile();// 获取用户选择文件
FileNameField.setText(file.getAbsolutePath());// 把选择的文件路径显示在文本框中
}
}

protected void do_OKbtn_actionPerformed(ActionEvent e, String ThisFile){
if (!ThisFile.equals("")) {
HowManyTab = 0;
ReadAndCombFile(ThisFile); // 文件名不能为空
}
}
// 根据{和}的个数决定每一行前面需要添加多少个tab空格
String FileInManyLines (String oneline, int CombRow, String Suffix) {
String PreffixStr; // 这是每一行开始的空格,它是用来方便阅读的
String TrimIt = oneline.trim();
String newoneline = "";
int Diff = 0;
// Java程序
if (Suffix.equals(".java")) {
int Conutleft = strFind(TrimIt, "{", 0);
int ConutRight = strFind(TrimIt, "}", 0);
Diff = Conutleft - ConutRight;
// 如果前面一行只有一个for, while or if但没有{},所以下面一行就缩进了
if ((Conutleft == 0) && (ConutRight == 0) && ForWhileIfBlock)
Diff = 50;
// for, while or if 开头,但是却没有使用{},说明这个块只有一行。
if ((Conutleft == 0) && (ConutRight == 0) && ((TrimIt.startsWith("for")) || (TrimIt.startsWith("while")) || (TrimIt.startsWith("if")) || (TrimIt.startsWith("else")) || (TrimIt.startsWith("else if")))) {
ForWhileIfBlock = true;
Diff= 100;
}
switch (Diff) {
case 1 : {
PreffixStr = ManyTabStr (HowManyTab, TabBlank);
HowManyTab = HowManyTab + 1;
newoneline = PreffixStr + TrimIt; // 把前缀空格添加到这一行前面
break;
}
case -1 : {
HowManyTab = HowManyTab - 1;
PreffixStr = ManyTabStr (HowManyTab, TabBlank);
newoneline = PreffixStr + TrimIt; // 把前缀空格添加到这一行前面
break;
}
case 0 : {
PreffixStr = ManyTabStr (HowManyTab, TabBlank);
newoneline = PreffixStr + TrimIt; // 把前缀空格添加到这一行前面
break;
}
case 50 :{
PreffixStr = ManyTabStr (HowManyTab, TabBlank);
newoneline = PreffixStr + TrimIt; // 把前缀空格添加到这一行前面
HowManyTab = HowManyTab - 1;
ForWhileIfBlock = false;
break;
}
case 100 : {
PreffixStr = ManyTabStr (HowManyTab, TabBlank);
newoneline = PreffixStr + TrimIt; // 把前缀空格添加到这一行前面
HowManyTab = HowManyTab + 1;
break;
}
default: {
PreffixStr = ManyTabStr (HowManyTab, TabBlank);
newoneline = PreffixStr + TrimIt; // 把前缀空格添加到这一行前面
System.out.println("第"+CombRow+"行"+"编写不规整, 请改正!");
HaveUnCleanRow = true; // 程序最后弹出对话框提醒用户这个程序有编写不规整的代 码。
}
}
} else if (Suffix.equals(".f90") || Suffix.equals(".f95")) { // Fortran程序
String LowCaseTrimIt = TrimIt.toLowerCase();
if (LowCaseTrimIt.startsWith("program") || LowCaseTrimIt.startsWith("module") || LowCaseTrimIt.startsWith("subroutine") || ((strFind(LowCaseTrimIt, "function", 0) == 1)) || LowCaseTrimIt.startsWith("do ") || (LowCaseTrimIt.startsWith("if") && (LowCaseTrimIt.endsWith("then"))) || LowCaseTrimIt.startsWith("select") || LowCaseTrimIt.startsWith("case")) {
Diff = 1;
}
else if (LowCaseTrimIt.startsWith("end ") || LowCaseTrimIt.startsWith("enddo") || LowCaseTrimIt.startsWith("endif")) {
Diff = 2;
}
else if (LowCaseTrimIt.startsWith("else")) {
Diff = 3;
}
else
{Diff = 100;}
switch (Diff) {
case 1 : {
PreffixStr = ManyTabStr (HowManyTab, TabBlank);
HowManyTab = HowManyTab + 1;
newoneline = PreffixStr + TrimIt; // 把前缀空格添加到这一行前面
break;
}
case 2 : {
HowManyTab = HowManyTab - 1;
PreffixStr = ManyTabStr (HowManyTab, TabBlank);
newoneline = PreffixStr + TrimIt; // 把前缀空格添加到这一行前面
break;
}
case 3 : {
HowManyTab = HowManyTab - 1;
PreffixStr = ManyTabStr (HowManyTab, TabBlank);
newoneline = PreffixStr + TrimIt; // 把前缀空格添加到这一行前面
HowManyTab = HowManyTab + 1;
break;
}
case 100 : {
PreffixStr = ManyTabStr (HowManyTab, TabBlank);
newoneline = PreffixStr + TrimIt; // 把前缀空格添加到这一行前面
break;
}
}
} else {// 其他格式的文件
newoneline = oneline;
}
return newoneline;
}
// 生成一个n个tab空格的空白字符串
String ManyTabStr (int howmany, String TabBlank) {
String Str = "";
for (int i = 0; i < howmany; i++)
Str = Str + TabBlank;
return Str;
}
// 方法strFind用于实现字符串查找,返回匹配的次数
public int strFind(String s1, String s2, int pos) {
// 变量i和j分别表示主串和模式串中当前字符串的位置,k 硎酒ヅ浯问
int i, j, k = 0;
// pos代表主串中开始比较的位置
// i=pos;
i = 0;// 如果把i=pos改成此句将不从鼠标位置开始找,而是直接 幼址房颊遥琲决定着开如查找的位置
j = 0;
while (i < s1.length() && j < s2.length()) {
if (s1.charAt(i) == s2.charAt(j)) {
++i;
++j;
if (j == s2.length()) {
// j=s2.length()表示字符串匹配成功,匹配成功次数加1
k = k + 1;
// 将指示主串和模式中当前字符的变量i和j进行回退
i = i - j + 1;
j = 0;
}
else {
i = i - j + 1;
j = 0;
}
}
i++;
}
return k;// 为什么这个while*环没有一个*环控制器呢,我还没有 斫馑慕峁梗
}

//以行为单位读取文件
String[] readFileByLines (String fileName){
File file = new File(fileName);
ArrayList<String> alllinks = new ArrayList<String>();
BufferedReader reader = null;//创建缓存读取
try {
reader = new BufferedReader(new FileReader(file));//将文件放在缓存读取中
String tempString = null;
//一次读入一行,直到读入null为文件结束
while ((tempString = reader.readLine()) != null){
alllinks.add(tempString);
}
reader.close();
} catch (IOException e) {//捕获异常
e.printStackTrace();
} finally {//内容总执行
if (reader != null) {
try {
reader.close();//关闭缓存读取
} catch (IOException e1) {
}
}
}
String[] links = new String[alllinks.size()];
for (int count = 0; count < alllinks.size(); count++) {links[count] = alllinks.get(count);}
return links;
}

// 把字符串数组写入文件, 即按行写入文件
public boolean stringArrayToFile(String[] arrayres, String filePath) {
boolean flag = true;
BufferedReader bufferedReader = null;
BufferedWriter bufferedWriter = null;
StringBuffer temp = new StringBuffer();
for (String one : arrayres) {
temp.append(one);
temp.append("\n");
}
int x = temp.lastIndexOf("\n");
temp.replace(x, temp.length(), "");
String res = temp.toString();
try {
File distFile = new File(filePath); //创建文件
if (!distFile.getParentFile().exists()) //判断父路径是文件夹是否存在
distFile.getParentFile().mkdirs(); //可以在不存在的目录中创建文件夹
bufferedReader = new BufferedReader(
new StringReader(res)); //将*字符串读入缓冲
bufferedWriter = new BufferedWriter(
new FileWriter(distFile)); //将文件写入缓冲
char buf[] = new char[1024]; // 字符缓冲区
int len;
while ((len = bufferedReader.read(buf)) != -1) { //while*环
bufferedWriter.write(buf, 0, len); //将字符串写入文件
}
bufferedWriter.flush(); //刷新写入流的缓冲
bufferedReader.close(); //关闭读出流
bufferedWriter.close(); //关闭写入流
} catch (IOException e) { //捕获异常
e.printStackTrace();
flag = false;
return flag;
} finally { //finally方法总被执行
if (bufferedReader != null) { //判断读出流是否为空
try {
bufferedReader.close(); //确保读出流关闭
} catch (IOException e) {
e.printStackTrace();
}
}
}
return flag; //返回布尔类型
}

void ReadAndCombFile (String filename) {
String[] FileDivideToManyLines = readFileByLines (filename);
// 获取文件的后缀名
int FileSuffixLoc = filename.lastIndexOf(".");
String FileSuffix = filename.substring(FileSuffixLoc, filename.length());
ArrayList<String> FileCombed = new ArrayList <String> (); // 储存加入合适前面空行的新的一行字符
int RowNumber = 1; // 记录现在处理第几行的代码,使用这个行数提醒开发者哪 里出错了
for (String oneline : FileDivideToManyLines) {
String newLine = FileInManyLines (oneline, RowNumber, FileSuffix);
FileCombed.add(newLine);
RowNumber = RowNumber + 1;
}
String[] FileCombInStr = new String[FileCombed.size()];
for (int count = 0; count < FileCombed.size(); count ++) {FileCombInStr [count] = FileCombed.get(count);}
stringArrayToFile (FileCombInStr, filename);
if (HaveUnCleanRow) {JOptionPane.showMessageDialog(null, "有不规整的代码,请改正。");}
}

public static void main(String[] args) {
Tidy TideFiles = new Tidy();
}
}
 
Reply With Quote
 
 
 
 
Novice
Guest
Posts: n/a
 
      03-02-2012
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote in
news:5690138.193.1330687781011.JavaMail.geo-discussion-forums@ynca15:

> The program can format Java codes, the codes formatted will have
> correct indent spaces.
>


> //----------
> /*
> Modified: 2012-3-1
> it can format java codes so as to get the correct indent spaces.
>
>
> */
> import java.io.IOException;//引入类
> import java.io.*;
> import java.io.BufferedReader;


[snip]

Are you simply trying to tell us that you have written a program that
formats Java source code so that we know? Or do you have a question of
some kind?

Also, are you aware that at least some popular IDEs already have built-in
source code editors with user-adjustable formatting? For example, Eclipse
has configurable editors so that you can tell it how many spaces you want
to indent, whether you want to use Tabs or Spaces, whether you want line
breaks before open braces or after close braces, etc. etc.

That means I'd have no real interest in using your program since my IDE
already does these things in a satisfactory way. I just mention this in
case you were hoping a lot of people would use or even buy this code.

--
Novice
 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      03-02-2012
On 03/02/2012 03:29 AM, (E-Mail Removed) wrote:
> The program can format Java codes, the codes formatted will have correct indent spaces.
>
> //----------
> /*
> Modified: 2012-3-1
> it can format java codes so as to get the correct indent spaces.
>
>
> */
> import java.io.IOException;//寮曞叆绫
> import java.io.*;


It is better to use single-type imports than import-on-demand. Certainly don't
do both on the same types.

> import java.io.BufferedReader;
> import java.io.BufferedWriter;
> import java.io.File;
> import java.io.FileWriter;
> import java.io.InputStreamReader;
> import java.io.StringReader;
> import java.io.StringWriter;
> import java.io.FileInputStream;
> import java.io.FileReader;
> import java.io.InputStream;
> import java.io.Reader;
> import java.util.ArrayList;
> import javax.swing.JOptionPane;
> import java.awt.event.*;
> import java.awt.*;
> import javax.swing.*;
> import java.awt.Graphics;


Don't mix single-type imports and import-on-demand for the same types.

> import java.awt.Color;
> import javax.swing.JFileChooser;
> import javax.swing.SwingConstants;
> import javax.swing.UIManager;
>
> public class Tidy extends JFrame {
> JButton SelectFilebtn, OKbtn;


The Java naming convention is to use lower-case first letter in variable and
method identifiers, and camel case thereafter. Thus, 'selectFileBtn', not
'SelectFilebtn'.

> JTextField FileNameField;
> String TabBlank = " "; // 姣忎竴娆ab鐨勭┖*煎ぇ灏忥紝杩欓噷涓洪粯璁ょ殑鍥涗釜绌烘*


Is there a tab in there? If so, you should use '\t' rather than an embedded TAB.

> int HowManyTab = 0;


There is no need to set the default value twice like this, except there's
really no harm, either. In this case you could argue that the redundant
initialization helps document your intent.

> boolean HaveUnCleanRow = false; // 璁板綍鏈夋病鏈夌紪鍐欎笉瑙勬暣鐨勭▼搴忎唬*侊紝濡傛灉鏈夊脊鍑哄璇濇璇风敤鎴锋敼*e啀鍏抽 *鎺у埗鍙帮紝濡傛灉娌℃湁锛屼笉鏄剧ず瀵硅瘽妗嗐
> boolean ForWhileIfBlock = false; // *囧織杩欎竴琛屾槸鍚or, while or if 寮澶翠絾鍗存病鏈墈}绗﹀彿锛岃繖璇存槑杩欎釜鍧楀彧 鏈変竴琛屻
> public Tidy () {


Your constructor is a bit unwieldy - too long and complicated. I suggest that
you refactor the fancy logic into a separate private method.

> this.setTitle( "鏂囦欢鏁寸悊鍣");
> setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
> this.setLayout(new GridBagLayout());
> GridBagConstraints gbc = new GridBagConstraints();
> gbc.anchor = GridBagConstraints.WEST; //璁惧畾Layout鐨勪綅缃
> gbc.insets = new Insets(2,2,2,2); //璁惧畾涓庤竟鐣岀殑璺濈(涓,宸,涓,鍙)
> SelectFilebtn = new JButton("閫夋嫨鏂囦欢");
> SelectFilebtn.addActionListener(new ActionListener() {
> public void actionPerformed(ActionEvent e) {
> do_SelectFilebtn_actionPerformed(e);
> }
> });
> FileNameField = new JTextField("",40);
> gbc.gridy=1;
> gbc.gridx=0;
> this.add(SelectFilebtn, gbc);
> gbc.gridx=1;
> this.add(FileNameField, gbc);
> //--------------
> OKbtn = new JButton("OK");
> OKbtn.addActionListener(new ActionListener() {
> public void actionPerformed(ActionEvent e) {
> String FileName = FileNameField.getText();
> do_OKbtn_actionPerformed(e, FileName);
> }
> });
> gbc.gridy=2;
> gbc.gridx=0;
> this.add(OKbtn, gbc);
> //---------------------
> this.pack();
> this.setVisible(true);
> }


I strongly recommend that the 'setVisible()' call happen after the constructor.

>
> protected void do_SelectFilebtn_actionPerformed (ActionEvent e) {


Why is this method 'protected'?

> JFileChooser chooser = new JFileChooser();// 鍒涘缓鏂囦欢閫夋嫨鍣
> int option = chooser.showOpenDialog(this);// 鏄剧ず鏂囦欢鎵撳紑瀵硅瘽妗
> if (option == JFileChooser.APPROVE_OPTION) {// 鍒ゆ*鐢ㄦ埛鏄惁閫夊畾鏂囦欢
> File file = chooser.getSelectedFile();// 鑾峰彇鐢ㄦ埛閫夋嫨鏂囦欢
> FileNameField.setText(file.getAbsolutePath());// 鎶婇夋嫨鐨勬枃浠惰矾寰勬樉绀哄湪鏂囨湰妗嗕*
> }
> }
>
> protected void do_OKbtn_actionPerformed(ActionEvent e, String ThisFile) {


Why is this method 'protected'?

Naming convention: 'thisFile', not 'ThisFile'.

> if (!ThisFile.equals("")) {


You forgot to check for the parameter being 'null'. This could cause a
'NullPointerException'. Tsk, tsk.

> HowManyTab = 0;
> ReadAndCombFile(ThisFile); // 鏂囦欢鍚嶄笉鑳戒负绌
> }
> }
> // *规嵁{鍜寎鐨勪釜鏁板喅瀹氭瘡涓琛屽墠闈㈤渶瑕佹坊鍔*澶氬皯涓猼ab绌烘*
> String FileInManyLines (String oneline, int CombRow, String Suffix) {


Why is this method package-private?

Naming convention. 'fileInManyLines()'. 'combRow'. 'suffix'.

> String PreffixStr; // 杩欐槸姣忎竴琛屽紑濮嬬殑绌烘*硷紝瀹冩槸鐢ㄦ潵鏂逛究闃呰鐨


There's only one "f" in "prefix". Don't put the type of the variable in the
name ("Str")!

> ... [snip] ...
> public static void main(String[] args) {
> Tidy TideFiles = new Tidy();
> }
> }


Start GUIs on the Event Dispatch Thread (EDT)!

Do file operations *off* the EDT!

I suggest reading the Swing tutorial and other references about Swing
programming. Also, study the Java coding conventions, around since 1999. Your
code is not thread-safe. Heck, it's not any kind of safe - you leave room for
runtime exceptions, you don't comment the strange parts of your logic (like
your switch on 'Diff' [sic] and the magic values it assumes). Your
pretty-print source is indented incorrectly - how good can your pretty-printer
be if you don't indent correctly in the first place? You don't control the
scope of your variables well ('i' and 'j' in 'strFind()', 'flag' and
'bufferedWriter' in 'stringArrayToFile()'), you don't declare constant those
that should be constants ('TabBlank' [sic]), and you redundantly initialize
variables ('BufferedReader reader = null;', 'int HowManyTab = 0;', etc.). You
declare methods as 'protected' or package-private willy-nilly without
explanation for the choices.

I will venture to guess that you wrote this as an exercise and though you
didn't explicitly say so, posted it here for critique. There are so many Java
pretty-printers out there already. Use one on your own code, why don't you?

Your code needs good formatting, proper naming, corrected access control,
controlled scope, controlled heritability, and the bugs eliminated.

--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedi.../c/cf/Friz.jpg
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      03-02-2012
On Fri, 2 Mar 2012 03:29:41 -0800 (PST), (E-Mail Removed) wrote,
quoted or indirectly quoted someone who said :

> PreffixStr =3D ManyTabStr (HowManyTab, TabBlank);
> HowManyTab =3D HowManyTab + 1;
> newoneline =3D PreffixStr + TrimIt; // =B0=D1=C7=B0=D7=
>=BA=BF=D5=B8=F1=CC=ED=BC=D3=B5=BD=D5=E2=D2=BB=D0= D0=C7=B0=C3=E6
> break;
> }
> case -1 : {


the process of posting on a newsreader is scrambling your code. Try
posting it somewhere and giving the URL.

see http://mindprod.com/jgloss/sscce.html
--
Roedy Green Canadian Mind Products
http://mindprod.com
One of the most useful comments you can put in a program is
"If you change this, remember to change ?XXX? too".

 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      03-02-2012
Roedy Green wrote:
> (E-Mail Removed) wrote, quoted or indirectly quoted someone who said :
>
>> PreffixStr =3D ManyTabStr (HowManyTab, TabBlank);
>> HowManyTab =3D HowManyTab + 1;
>> newoneline =3D PreffixStr + TrimIt; // =B0=D1=C7=B0=D7=
>> =BA=BF=D5=B8=F1=CC=ED=BC=D3=B5=BD=D5=E2=D2=BB=D0=D 0=C7=B0=C3=E6
>> break;
>> }
>> case -1 : {

>
> the process of posting on a newsreader is scrambling your code. Try
> posting it somewhere and giving the URL.
>
> see http://mindprod.com/jgloss/sscce.html


He *gave* us an SSCCE, already!

It wasn't scrambled here. Perhaps it's something specific to your newsreader.
It clearly wasn't scrambled by "the process of posting on a newsreader" or
everyone would've seen the problem.

His code even survived my newsreader placing it into the reply as "quoted
text", without loss of formatting or other issues. Does the quoted code look
scrambled in my reply? That would be a good data point.

I do note however that your reply is scrambled, in the sense that it didn't
transcribe the Chinese characters. I infer that your newsreader used the wrong
text encoding. You should fix that.

I recommend against the OP's posting the code on a separate URL. It's easier
to get answers when the respondents have everything they need in one place. I
was grateful that they included their SSCCE in their post.

--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedi.../c/cf/Friz.jpg
 
Reply With Quote
 
Lars Enderin
Guest
Posts: n/a
 
      03-02-2012
2012-03-02 19:04, Roedy Green skrev:
> On Fri, 2 Mar 2012 03:29:41 -0800 (PST), (E-Mail Removed) wrote,
> quoted or indirectly quoted someone who said :
>
>> PreffixStr =3D ManyTabStr (HowManyTab, TabBlank);
>> HowManyTab =3D HowManyTab + 1;
>> newoneline =3D PreffixStr + TrimIt; // =B0=D1=C7=B0=D7=
>> =BA=BF=D5=B8=F1=CC=ED=BC=D3=B5=BD=D5=E2=D2=BB=D0=D 0=C7=B0=C3=E6
>> break;
>> }
>> case -1 : {

>
> the process of posting on a newsreader is scrambling your code. Try


Blame your own newsreader! I had no trouble reading the OP with
Thunderbird, Chinese comments and all.
The headers are a bit unusual, granted:
Content-Type: text/plain; charset=GB2312
Content-Transfer-Encoding: quoted-printable
(which your newsreader ignores completely)

> posting it somewhere and giving the URL.


--
Lars Enderin
 
Reply With Quote
 
Arne Vajh鴍
Guest
Posts: n/a
 
      03-02-2012
On 3/2/2012 1:04 PM, Roedy Green wrote:
> On Fri, 2 Mar 2012 03:29:41 -0800 (PST), (E-Mail Removed) wrote,
> quoted or indirectly quoted someone who said :
>> PreffixStr =3D ManyTabStr (HowManyTab, TabBlank);
>> HowManyTab =3D HowManyTab + 1;
>> newoneline =3D PreffixStr + TrimIt; // =B0=D1=C7=B0=D7=
>> =BA=BF=D5=B8=F1=CC=ED=BC=D3=B5=BD=D5=E2=D2=BB=D0=D 0=C7=B0=C3=E6
>> break;
>> }
>> case -1 : {

>
> the process of posting on a newsreader is scrambling your code. Try
> posting it somewhere and giving the URL.


You need a newsreader that understands Quoted Printable.

Something from late 90's or later should support that.

Arne

 
Reply With Quote
 
gearss8888@gmail.com
Guest
Posts: n/a
 
      03-02-2012
I am a Java beginner, perhaps it is my third Java program, sorry for my poor skill in Java. I donot use Eclipse to write Java codes, it is not good ateditting codes, I prefer notepad ++ (http://notepad-plus-plus.org/download/v5.9.8.html) and SciTE(http://www.scintilla.org), Eclipse is a good integrated tool for developing Java program, but it is not the suitable editor topurely edit codes. I learn a lot from people's comment, later I will continue to post my codes here for comments.
I donot know how to post long codes, I donot have space to attach my program.
 
Reply With Quote
 
Arne Vajh鴍
Guest
Posts: n/a
 
      03-03-2012
On 3/2/2012 6:55 PM, (E-Mail Removed) wrote:
> I am a Java beginner, perhaps it is my third Java program, sorry for my poor skill in Java. I donot use Eclipse to write Java codes, it is not good at editting codes, I prefer notepad ++ (http://notepad-plus-plus.org/download/v5.9.8.html) and SciTE(http://www.scintilla.org), Eclipse is a good integrated tool for developing Java program, but it is not the suitable editor to purely edit codes. I learn a lot from people's comment, later I will continue to post my codes here for comments.
> I donot know how to post long codes, I donot have space to attach my program.


I think you will find out that >95% of Java developers use Eclipse or
similar Java IDE to edit Java code.

Arne

 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      03-03-2012
On 03/02/2012 03:55 PM, (E-Mail Removed) wrote:
> I am a Java beginner, perhaps it is my third Java program, sorry for my poor skill in Java. I donot use Eclipse to write Java codes, it is not good at editting codes, I prefer notepad ++ (http://notepad-plus-plus.org/download/v5.9.8.html) and SciTE(http://www.scintilla.org), Eclipse is a good integrated tool for developing Java program, but it is not the suitable editor to purely edit codes. I learn a lot from people's comment, later I will continue to post my codes here for comments.
> I donot know how to post long codes, I donot have space to attach my program.


I disagree. Eclipse is entirely suitable as a code editor, even if you ignore
all its other features. Ditto NetBeans. Ditto many others.

I am interested in the details of why you find Eclipse unsuitable. What are they?

Don't post long programs. Post simple, short, complete, compilable examples
(SSCCEs) that reveal your difficulty.
http://sscce.org/

What you posted in the beginning was an SSCCE. It was enough from my point of
view, anyway.

As for not having space to attach your programs, sure you do. You've already
done it. Not that you should attach anything, you should do exactly as you did
and include it in the body of your post.

However, this is a discussion group, so when people ask you questions you
should participate in the discussion.

> Novice wrote:
>> Are you simply trying to tell us that you have written a program that
>> formats Java source code so that we know? Or do you have a question of
>> some kind?


He has a point. We don't know why you came to us. Why did you?

--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedi.../c/cf/Friz.jpg
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to write codes to connect access database using html codes hiralcp Software 0 12-18-2007 08:49 PM
How to use file I/o codes with form and controls codes Allen ASP .Net 1 12-03-2007 12:04 AM
what class to use to develop a program which downloads files from ftp when running. xz Java 2 09-06-2007 03:40 AM
Virtual Key Codes, Scan Codes and ASCII Codes in C gj_williams2000@yahoo.co.uk C Programming 2 08-20-2005 11:04 AM
RegEx replace of html codes to ascii codes Greg -- ASP .Net 4 08-09-2005 07:27 PM



Advertisments