不想当厨师的学徒不是好学徒,不想当老板的员工不是好员工,不想开花结果的恋爱都是耍流氓。不想当java大神的学员不是好学员,学习java,就是为了提高自己的java技术,所以如何从java小白变成java大神呢?
1.合理安排时间,花时间专注于写代码
有人说这还不容易吗?我每天的工作就是写代码,花的时间远远是你想不到的。其实,问问你自己真的在写代码时全身心的投入进去了吗?没有把时间花在开会、喝茶、聊天、吃饭上吗?
有人又说,在职场身不由己。对。在职场是很难把时间纯粹花在写代码上。这也是很多程序员讨厌在工作中被人打扰的原因。所以,建议你,合理安排自己的时间,花时间专注于写代码,提高你自身的技能。
2.配合开发团队,善于从团队成员中学习新东西
作为开发团队中的一员,你必须与你的开发团队中的其他成员一起共事,无论你的个性有多么独特突出。俗话说的好,“三人行必有我师焉”,你配合好开发团队的工作,你就会从开发团队其他成员中学习到很多不一样的东西,并且,团队氛围其乐融融,你工作也会乐在其中,外界干扰因素也会大大减少。
3.敢于挑战新的开发团队,离开长期相同的工作
Java小白在一个开发团队待久了,慢慢的工作中所需要的技能都掌握了,那么就会陷入到一个死胡同,每天都是相同的工作,技能真的很难得到新的提升。这时候找家新的开发团队就很重要,既可以保持自己编程的活力,又可以从新的开发团队身上学习新的内容。所以,敢于挑战新的开发团队,离开长期相同的工作,也是你挑战自己新的开始。
4.学习java永无止境
学习java无止境,当下软件技术更新的日新月异,每天无数编程技能在你还未察觉的时候就已经被淘汰,所以你想要在java领域长期发展,北大青鸟http://www.kmbdqn.cn/认为你就必须时时刻刻关注新的编程语言和技术趋势,不要满足于当下你java学的多么牛,要保持如饥似渴的态度和持续的激情,永无止境的学习java。
先请编译和运行下面程序:import java.util.*
import java.io.*
public class BadExecJavac2
{
public static void main(String args[])
{
try
{
Runtime rt = Runtime.getRuntime()
Process proc = rt.exec("javac")
int exitVal = proc.waitFor()
System.out.println("Process exitValue: " + exitVal)
} catch (Throwable t){
t.printStackTrace()
}
}
}
我们知道javac命令,当不带参数运行javac
程序时,它将输出帮助说明,为什么上面程序不产生任何输出并挂起,永不完成呢?java文档上说,由于有些本地平台为标准输入和输出流所提供的缓冲区大小
有限,如果不能及时写入子进程的输入流或者读取子进程的输出流,可能导致子进程阻塞,甚至陷入死锁。所以,上面的程序应改写为:
import java.util.*
import java.io.*
public class MediocreExecJavac
{
public static void main(String args[])
{
try
{
Runtime rt = Runtime.getRuntime()
Process proc = rt.exec("javac")
InputStream stderr = proc.getErrorStream()
InputStreamReader isr = new InputStreamReader(stderr)
BufferedReader br = new BufferedReader(isr)
String line = null
System.out.println("")
while ( (line = br.readLine()) != null)
System.out.println(line)
System.out.println("")
int exitVal = proc.waitFor()
System.out.println("Process exitValue: " + exitVal)
} catch (Throwable t){
t.printStackTrace()
}
}
}
下面是正确的输出:
D:\java>java MediocreExecJavac
Usage: javac <options>
where possible options include:
-g Generate all debugging info
-g:noneGenerate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarnGenerate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are used
-classpath Specify where to find user class files
-cp Specify where to find user class files
-sourcepath Specify where to find input source files
-bootclasspath Override location of bootstrap class files
-extdirs Override location of installed extensions
-endorseddirsOverride location of endorsed standards path
-d Specify where to place generated class files
-encodingSpecify character encoding used by source files
-source Provide source compatibility with specified release
-target Generate class files for specific VM version
-version Version information
-help Print a synopsis of standard options
-X Print a synopsis of nonstandard options
-J Pass directly to the runtime system
Process exitValue: 2
D:\java>
下面是一个更一般的程序,它用两个线程同步清空标准错误流和标准输出流,并能根据你所使用的windows操作系统选择windows命令解释器command.com或cmd.exe,然后执行你提供的命令。
import java.util.*
import java.io.*
class StreamGobbler extends Thread
{
InputStream is
String type //输出流的类型ERROR或OUTPUT
StreamGobbler(InputStream is, String type)
{
this.is = is
this.type = type
}
public void run()
{
try
{
InputStreamReader isr = new InputStreamReader(is)
BufferedReader br = new BufferedReader(isr)
String line=null
while ( (line = br.readLine()) != null)
{
System.out.println(type + ">" + line)
System.out.flush()
}
} catch (IOException ioe)
{
ioe.printStackTrace()
}
}
}
public class GoodWindowsExec
{
public static void main(String args[])
{
if (args.length <1)
{
System.out.println("USAGE: java GoodWindowsExec ")
System.exit(1)
}
try
{
String osName = System.getProperty("os.name" )
System.out.println("osName: " + osName)
String[] cmd = new String[3]
if(osName.equals("Windows XP") ||osName.equals("Windows 2000"))
{
cmd[0] = "cmd.exe"
cmd[1] = "/C"
cmd[2] = args[0]
}
else if( osName.equals( "Windows 98" ) )
{
cmd[0] = "command.com"
cmd[1] = "/C"
cmd[2] = args[0]
}
Runtime rt = Runtime.getRuntime()
System.out.println("Execing " + cmd[0] + " " + cmd[1]+ " " + cmd[2])
Process proc = rt.exec(cmd)
// any error message?
StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(), "ERROR")
// any output?
StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(), "OUTPUT")
// kick them off
errorGobbler.start()
outputGobbler.start()
// any error???
int exitVal = proc.waitFor()
System.out.println("ExitValue: " + exitVal)
} catch (Throwable t){
t.printStackTrace()
}
}
}
下面是一个测试结果:
D:\java>java GoodWindowsExec "copy Test.java Test1.java"
osName: Windows XP
Execing cmd.exe /C copy Test.java Test1.java
OUTPUT>已复制 1 个文件。
ExitValue: 0
D:\java>
下面的测试都能通过(windows xp+jdk1.5)
D:\java>java GoodWindowsExec dir
D:\java>java GoodWindowsExec Test.java
D:\java>java GoodWindowsExec regedit.exe
D:\java>java GoodWindowsExec NOTEPAD.EXE
D:\java>java GoodWindowsExec first.ppt
D:\java>java GoodWindowsExec second.doc
function TempSave(ElementID)
{
CommentsPersistDiv.setAttribute("CommentContent",document.getElementById(ElementID).value)
CommentsPersistDiv.save("CommentXMLStore")
}
function Restore(ElementID)
{
CommentsPersistDiv.load("CommentXMLStore")
document.getElementById(ElementID).value=CommentsPersistDiv.getAttribute("CommentContent")
}