每次想参考一些好看网站的时候,打开css文档都是一行的,琢磨了下就自己写了块短短的代码,各路Java大神别笑我呀。^_^

复制粘贴控制台的输出就好了。(瞬间觉得跟上大神的脚步了←_←)

package sortingAlgorithm;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.logging.Level;
import java.util.logging.Logger; /**
*
* @author xzh
*/
public class test {
public static void main(String[] args){
try {
FileInputStream fis = new FileInputStream("./style.css");
InputStreamReader insr = new InputStreamReader(fis,"utf-8");
BufferedReader bufr = new BufferedReader(insr);
String oneLine = "";
String tmp;
while((tmp=bufr.readLine())!=null){
oneLine += tmp;
}
String result = "";
for(int i=0;i<oneLine.length();i++){
char ch = oneLine.charAt(i);
switch (ch){
case '{':
result += "{\n\t";
break;
case '}':
result += "\n}\n";
break;
case ';':
if(oneLine.charAt(i+1)!='}'){
result += ";\n\t";
}else{
result += ";\n";
}
break;
default :
result += ch;
}
}
System.out.println(result);
} catch (FileNotFoundException | UnsupportedEncodingException ex) {
Logger.getLogger(test.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(test.class.getName()).log(Level.SEVERE, null, ex);
}
}
}

  

Let's Format Css Documents的更多相关文章

  1. WeasyPrint - Converts HTML + CSS to PDF - WeasyPrint converts HTML/CSS documents to PDF

    WeasyPrint - Converts HTML + CSS to PDF - WeasyPrint converts HTML/CSS documents to PDF WeasyPrint c ...

  2. Create and format Word documents using R software and Reporters package

    http://www.sthda.com/english/wiki/create-and-format-word-documents-using-r-software-and-reporters-pa ...

  3. sublime格式化css代码插件:css format

    有时会从网上下载一些css压缩文件,打开后所有代码都在一行,不利于阅读,通过css format插件,能快速展开代码,方便阅读. 参考:Sublime Text 上最好用的 CSS 格式化插件 —— ...

  4. 聊聊CSS postproccessors

      阿里妈妈 @一丝 准备发布其CSSGrace,即CSS后处理插件,于是顺便聊聊CSS postprocessors. 从Rework说起 Rework是TJ大神开发的CSS预处理框架.但为什么会出 ...

  5. 给初学者的20个CSS实用建议

    英文原文:20-useful-css-tips-for-beginners,编译:杨礼鑫 过去就连一个镜像站点,我们都依靠大量的开发人员和程序员进行维护.得益于CSS和它的灵活性使得样式能够从代码中被 ...

  6. 20个初学者实用的CSS技巧

    过去就连一个镜像站点,我们都依靠大量的开发人员和程序员进行维护.得益于CSS和它的灵活性使得样式能够从代码中被独立抽离出来,从而让一个只具备基本CSS理论的初学者都能够轻易地改变网站的样式. 不论你是 ...

  7. Why are dashes preferred for CSS selectors / HTML attributes?

    Why are dashes preferred for CSS selectors / HTML attributes? I use dashes because I don't have to h ...

  8. 【RobotFramework】Selenium2Library类库关键字使用说明

    Add CookieArguments:[ name | value | path=None | domain=None | secure=None | expiry=None ]Adds a coo ...

  9. AsciiDoc

    AsciiDoc Text based document generation AsciiDoc Home Page Table of Contents Introduction Overview a ...

随机推荐

  1. JavaScript 工作必知(九)function 说起 闭包问题

    大纲 Function Caller 返回函数调用者 Callee 调用自身 作用域 闭包 function 函数格式 function getPrototyNames(o,/*optional*/ ...

  2. java 解析json的问题

    本文转载自http://chriszz.sinaapp.com/?p=392 Json就是Javascript notation,可以替代XML,用做数据交互. Json的两种基本表示形式,可以用自动 ...

  3. 网页平面设计 HTML

    网页平面设计HTML基础 1.网页的基本元素:文字.图像.超链接 2.HTML的基本机构head.title.body三部分 <html> <head> <title&g ...

  4. window.onload()与$(document).ready()区别

    浏览器加载完DOM后,会通过javascript为DOM元素添加事件,在javascript中,通常使用window.onload()方法. 在jquery中,则使用$(document).ready ...

  5. TFS跨版本Merge测试

    原始文件Merge.txt Change Set Dev Beta #1 2014-9-25 10:49:13 ZDK 2014-9-25 10:49:13 ZDK #2 2014-9-25 10:4 ...

  6. Error 56: …… VPN Service has not been started

    vpn service在系统服务中名为Cisco System, Inc. VPN Service(cvpnd),异常情况下,该服务时停止的,并且手动启动该服务后没几秒,就被kill了.根据Zhiga ...

  7. Csharp实现快速排序

    public void QuickSort(int[] arr, int left, int right) //快速排序 { //先从数列中去处一个数作为基准数 //分区过程,将比这个数大的数全放在他 ...

  8. TreeSet()详解

    TreeSet()详解   1.TreeSet原理:   /* * TreeSet存储对象的时候, 可以排序, 但是需要指定排序的算法 *  * Integer能排序(有默认顺序), String能排 ...

  9. Apache配置参数

    Apache的配置文件 配置文件所在目录:/etc/httpd/conf/主配置文件:httpd.conf旧版本中的配置文件:资源配置文件:srm.conf访问许可权配置文件:access.conf ...

  10. CSS自学笔记(7):CSS定位

    很多时候,我们需要对一些元素进行自定义排序.布局等,这是就需要用到CSS的定位属性了,用这些属性对一些元素进行自定义排序.布局等操作,可以改变浏览器默认的死板的排序. CSS定位的功能很容易理解,它允 ...